Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPattern ¶
func RegisterPattern(pattern string, handler http.HandlerFunc)
RegisterPattern associates the given URL path with the given handler. Call this from an init() function. Whenever a user navigates to the given pattern, the handler will be called. Note that the pattern should NOT include the RestPathPrefix.
Types ¶
type DefaultApiManager ¶
type DefaultApiManager struct {
Mux Muxer
}
The DefaultApiManager type represents the default api manager that is created at bootup. The Mux variable can be replaced with the Muxer of your choice.
func NewDefaultApiManager ¶
func NewDefaultApiManager() DefaultApiManager
Creates a new api manager that uses config.ApiPrefix as a path prefix to determine if the given call is a REST call. It also uses Go's standard ServeMux as a muxer to direct which handler should handle the request. The Mux is public, so you can replace it with your own Muxer if desired.
func (DefaultApiManager) HandleRequest ¶
func (a DefaultApiManager) HandleRequest(w http.ResponseWriter, r *http.Request) (isApiCall bool)
func (DefaultApiManager) RegisterPattern ¶
func (a DefaultApiManager) RegisterPattern(pattern string, handler http.Handler)
type HttpError ¶
type HttpError struct {
// contains filtered or unexported fields
}
HttpError represents an error response to a http request.
func (*HttpError) SetResponseHeader ¶
SetResponseHeader sets a key-value in the header response.
type Muxer ¶
type Muxer interface {
// Handle associates a handler with the given pattern in the url path
Handle(pattern string, handler http.Handler)
// ServeHTTP sends a request to the MUX, to be forwarded on to the registered handler,
// or responded with an unknown resource error.
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
Muxer represents the typical functions available in a mux and allows you to replace the default Golang muxer here with a 3rd party mux, like the Gorilla mux.