Bad HTTP status code 400
const Bad = 400
Err HTTP status code 500
const Err = 500
NoService HTTP status code 503
const NoService = 503
NotFound HTTP status code 404
const NotFound = 404
Ok HTTP status code 200
const Ok = 200
Type Mesh network server type for HTTP server
const Type = "HTTP"
func Command(method string, uri string, handler func(*Response, *Request, *Params, func(error)))
Command Registers a handler for a given URL
func Delete(uri string, handler func(*Response, *Request, *Params, func(error)))
Delete Registers a handler for a DELETE method URL
func Get(uri string, handler func(*Response, *Request, *Params, func(error)))
Get Registers a handler for a GET method URL
func GetRealTimeNodeEndpoint(list []string) string
GetRealTimeNodeEndpoint returns a WebSocket/TC/UDP server endpoint Returns a node endpoint that is not taken and online
func HandleStaticFiles(uriRoot string, fsPath string)
HandleStaticFiles handle static files
func Head(uri string, handler func(*Response, *Request, *Params, func(error)))
Head Registers a handler for a HEAD method URL
func Offline()
Offline Sets mesh network status to offline
func OnAuthRequest(handler func(res *Response, req *Request, params *Params, next func(error)))
OnAuthRequest hooks a request handler function to auth request. If invoked before SetupAsAuthServer(), the hook will be called BEFORE the actual auth handling. If invoked after SetupAsAuthServer(), the hook will be called AFTER.
func Online()
Online Sets mesh network status to online
func Options(uri string, handler func(*Response, *Request, *Params, func(error)))
Options Registers a handler for an OPTIONS method URL
func Post(uri string, handler func(*Response, *Request, *Params, func(error)))
Post Registers a handler for a POST method URL
func Put(uri string, handler func(*Response, *Request, *Params, func(error)))
Put Registers a handler for a PUT method URL
func SetAllowOrigin(origin string)
SetAllowOrigin sets Access-Control-Allow-Origin response header for CORS
func SetCustomNodeSelector(selector func([]string) string)
SetCustomNodeSelector replaces the default node selector with custom selector for Auth
func Setup(confpath string)
Setup Loads configuration file into memory - pass an empty string to load nothing
func SetupAsAuthServer(path string)
SetupAsAuthServer Sets Up HTTP server as Auth server for TCP/UDP - pass an empty string to load nothing
func ShutdownHTTP(next func(error))
ShutdownHTTP Stops HTTP server
func Start(next func(error))
Start Starts HTTP server
Params URL parameter data structure
type Params struct { Values map[string]string }
func (params *Params) GetAsBool(name string) (bool, error)
GetAsBool Returns a URL parameter value as a boolean
func (params *Params) GetAsFloat64(name string) (float64, error)
GetAsFloat64 Returns a URL parameters value as a float64
func (params *Params) GetAsInt(name string) (int, error)
GetAsInt Returns a URL parameter value as an int
func (params *Params) GetAsInt16(name string) (int16, error)
GetAsInt16 Returns a URL parameter value as an int16
func (params *Params) GetAsInt32(name string) (int32, error)
GetAsInt32 Returns a URL parameter value as an int32
func (params *Params) GetAsInt64(name string) (int64, error)
GetAsInt64 Returns a URL parameter value as an int64
func (params *Params) GetAsInt8(name string) (int8, error)
GetAsInt8 Returns a URL parameter value as an int8
func (params *Params) GetAsString(name string) (string, error)
GetAsString a URL parameter value as a string
func (params *Params) GetAsUint16(name string) (uint16, error)
GetAsUint16 Returns a URL parameter value as a uint16
func (params *Params) GetAsUint32(name string) (uint32, error)
GetAsUint32 Returns a URL parameter value as a uint32
func (params *Params) GetAsUint64(name string) (uint64, error)
GetAsUint64 Returns a URL parameter value as a uint64
func (params *Params) GetAsUint8(name string) (uint8, error)
GetAsUint8 Returns a URL parameter value as a uint8
Request Request data structure
type Request struct { Method string URL string Queries map[string][]string Req *http.Request }
func (req *Request) GetPostData(name string) string
GetPostData Returns postMethod body data by name
Response Response data structure
type Response struct { Method string URI string Writer http.ResponseWriter Finished bool }
func (res *Response) Respond(data string, status int)
Respond Sends a response packet and HTTP status code
func (res *Response) SendBytes(data []byte, status int)
SendBytes sends a response as binary data
func (res *Response) SetHeader(name, value string)
SetHeader sets a custom response header
Route URL route data structure
type Route struct { Route string Finder *regexp.Regexp Extractor *regexp.Regexp Handlers []func(*Response, *Request, *Params, func(error)) ParamNames []string }