Documentation ¶
Index ¶
Constants ¶
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" HEAD = "HEAD" PATCH = "PATCH" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
An API manages a group of resources by routing requests to the correct method on a matching resource and marshalling the returned data to JSON for the HTTP response.
You can instantiate multiple APIs on separate ports. Each API will manage its own set of resources.
func (*API) AddResource ¶
AddResource adds a new resource to an API. The API will route requests that match one of the given paths to the matching HTTP method on the resource.
func (*API) AddResourceWithWrapper ¶
func (api *API) AddResourceWithWrapper(resource interface{}, wrapper func(handler http.HandlerFunc) http.HandlerFunc, paths ...string)
AddResourceWithWrapper behaves exactly like AddResource but wraps the generated handler function with a give wrapper function to allow to hook in Gzip support and similar.
func (*API) Mux ¶
Mux returns the muxer used by an API. If a ServeMux does not yet exist, a new *http.ServeMux will be created and returned.
type APIMux ¶
type APIMux interface { HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) *mux.Route ServeHTTP(w http.ResponseWriter, r *http.Request) }
Interface for arbitrary muxer support (like http.ServeMux).
type DeleteSupported ¶
DeleteSupported is the interface that provides the Delete method a resource must support to receive HTTP DELETEs.
type GetSupported ¶
GetSupported is the interface that provides the Get method a resource must support to receive HTTP GETs.
type HeadSupported ¶
HeadSupported is the interface that provides the Head method a resource must support to receive HTTP HEADs.
type PatchSupported ¶
PatchSupported is the interface that provides the Patch method a resource must support to receive HTTP PATCHs.
type PostSupported ¶
PostSupported is the interface that provides the Post method a resource must support to receive HTTP POSTs.