Documentation ¶
Index ¶
- Constants
- func AuthenticatedEndpoint(endpoint, headerName string, validateFunc func(string) error, ...)
- func Endpoint(endpoint string, handler HttpFunction)
- func GetIpAddress(r *http.Request) string
- func JsonEndpoint(endpoint string, handler func(http.ResponseWriter, *http.Request) interface{})
- func Listen()
- type HttpFunction
Constants ¶
View Source
const ( // Context to use when logging Context = "WEBSERVER" // HeaderIpAddress to use to get the user's IP address HeaderIpAddress = `X-Forwarded-For` // HeaderCors is used to enable CORS without needing intermediating // proxy code HeaderCorsAllowOrigin = `Access-Control-Allow-Origin` // HeaderCorsAllowHeaders is also used to support permissive CORS HeaderCorsAllowHeaders = `Access-Control-Allow-Headers` // EnvHttpListenAddress to use to listen on EnvHttpListenAddress = `FLU_WEB_LISTEN_ADDR` )
View Source
const StatusValidationFuncFailed = 403
StatusValidationFuncFailed is returned when the validation func returns a non-nil exit code!
Variables ¶
This section is empty.
Functions ¶
func AuthenticatedEndpoint ¶
func AuthenticatedEndpoint(endpoint, headerName string, validateFunc func(string) error, handler HttpFunction)
AuthenticatedEndpoint listens using http.HandleFunc on a specific endpoint, with some overhead for logging and a pass to validate whether the connection should continue. Also enables CORS!
func Endpoint ¶
func Endpoint(endpoint string, handler HttpFunction)
Endpoint adds some logging code to handle user requests. Also enables CORS!
func GetIpAddress ¶
GetIpAddress from a request with HeaderIpAddress
func JsonEndpoint ¶
func JsonEndpoint(endpoint string, handler func(http.ResponseWriter, *http.Request) interface{})
JsonEndpoint adds some logging code and marshals the return value of the handler and sends to the client. If the interface{} is nil, then nothing happens.
Types ¶
type HttpFunction ¶
type HttpFunction func(http.ResponseWriter, *http.Request)
HttpFunction to destink function definitions
Click to show internal directories.
Click to hide internal directories.