servito

package module
v0.0.0-...-5ecf0b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2018 License: MIT Imports: 11 Imported by: 0

README

Servito

Build Status GoDoc

A small HTTP server in Go. A great start for small projects and prototyping.

Install

$ go get github.com/ghawk1ns/servito

Example

https://github.com/GHawk1ns/Servito/blob/master/example/main.go

Config

You can set these values individually or pass servito a JSON string, file, or path to a json file

{
  "debug": true,
  "address": string,
  "port": string,
  "readTimeout": int,
  "writeTimeout": int,
  "csrfEnable", bool,
  "CSRFKey", string
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInterceptor

func AddInterceptor(fn RequestInterceptor)

func AddRoute

func AddRoute(name string, method string, pattern string, handlerFunction http.HandlerFunc)

func LoadConfigFromFile

func LoadConfigFromFile(file *os.File)

func LoadConfigFromJSON

func LoadConfigFromJSON(configJSON string)

func LoadConfigFromPath

func LoadConfigFromPath(configPath string)

func SetAddress

func SetAddress(address string)

func SetDebug

func SetDebug(debug bool)

func SetPort

func SetPort(port string)

func StartServer

func StartServer()

Starts a servito with the default config

Types

type RequestInterceptor

type RequestInterceptor func(http.ResponseWriter, *http.Request) bool

Intercepts all incoming requests and passes control over the user. If the request was handled, RequestInterceptor should return true. This means the request will not be routed to the original target

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL