Documentation ¶
Index ¶
- func WriteResponse(w http.ResponseWriter, response interface{})
- type Config
- type HTTPError
- type HTTPRequestInfo
- type HTTPResponse
- type ResponseWriter
- type Server
- func (s *Server) HeadersMiddleware(next http.Handler) http.Handler
- func (s *Server) LoggingMiddleware(next http.Handler) http.Handler
- func (s *Server) RegisterAction(path string, handler func(http.ResponseWriter, *http.Request), ...)
- func (s *Server) RegisterAssetsDirectory(pathPrefix string, directory string)
- func (s *Server) RegisterHeader(key, value string)
- func (s *Server) RegisterMiddleware(middlewares ...mux.MiddlewareFunc)
- func (s *Server) Run()
- func (s *Server) SetNotFoundHandler(handler func(http.ResponseWriter, *http.Request))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, response interface{})
WriteResponse does one of two things.
1. If the response parameter is a HTTPError its private message and status code will be logged, then the public message will be written to the response body.
2. If the response parameter is not a HTTPError it will be marshaled and then written to the response body.
Types ¶
type HTTPRequestInfo ¶
type HTTPRequestInfo struct { StatusCode int Method string URI string Duration time.Duration Length int IPAddress string Referer string UserAgent string Protocol string }
HTTPRequestInfo stores all the relevant information from an incoming HTTP request.
type HTTPResponse ¶
type HTTPResponse struct { Data interface{} `json:"data"` ErrorMessage string `json:"errorMessage"` }
HTTPResponse is for writing an outgoing response to a HTTP request, it stores response data and an optional error message.
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter StatusCode int Length int }
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(statusCode int)
type Server ¶
func (*Server) HeadersMiddleware ¶
func (*Server) LoggingMiddleware ¶
func (*Server) RegisterAction ¶
func (*Server) RegisterAssetsDirectory ¶
func (*Server) RegisterHeader ¶
func (*Server) RegisterMiddleware ¶
func (s *Server) RegisterMiddleware(middlewares ...mux.MiddlewareFunc)
func (*Server) SetNotFoundHandler ¶
func (s *Server) SetNotFoundHandler(handler func(http.ResponseWriter, *http.Request))
Click to show internal directories.
Click to hide internal directories.