Documentation ¶
Index ¶
- Variables
- func StatusAccepted(e he.NetEntity) he.Response
- func StatusBadRequest(e he.NetEntity) he.Response
- func StatusConflict(entity he.NetEntity) he.Response
- func StatusCreated(parent he.EntityGroup, childName string, req he.Request) he.Response
- func StatusForbidden(e he.NetEntity) he.Response
- func StatusFound(u *url.URL) he.Response
- func StatusGone(entity he.NetEntity) he.Response
- func StatusInternalServerError(err interface{}) he.Response
- func StatusMethodNotAllowed(entity he.Entity, request he.Request) he.Response
- func StatusMovedPermanently(u *url.URL) he.Response
- func StatusMultipleChoices(u *url.URL, mimetypes []string) he.Response
- func StatusNoContent() he.Response
- func StatusNotAcceptable(u *url.URL, mimetypes []string) he.Response
- func StatusNotFound(e he.NetEntity) he.Response
- func StatusNotImplemented(e he.NetEntity) he.Response
- func StatusOK(entity he.NetEntity) he.Response
- func StatusResetContent() he.Response
- func StatusSeeOther(u *url.URL) he.Response
- func StatusTemporaryRedirect(u *url.URL) he.Response
- func StatusUnsupportedMediaType(e he.NetEntity) he.Response
Constants ¶
This section is empty.
Variables ¶
var Middleware = he.Middleware{ Inside: func(request he.Request, entity he.Entity, handle func(he.Request, he.Entity) he.Response) (response he.Response) { switch request.Method { case "OPTIONS": response := handle(request, entity) if response.Status == 405 { methods := entity.Methods() response.Headers.Set("Allow", methods2string(methods)) } response.Status = 204 response.Entity = nil case "HEAD": request.Method = "GET" response := handle(request, entity) response.Entity = nil default: response = handle(request, entity) } if response.Status == 405 { methods := entity.Methods() response.Headers.Set("Allow", methods2string(methods)) } if l := response.Headers.Get("Location"); l != "" { u2, _ := request.URL.Parse(l) response.Headers.Set("Location", u2.String()) } return }, }
Middleware is a good default middleware for httpentity that provides much of the boilerplate for RFC 7231 semantics.
Functions ¶
func StatusAccepted ¶
For when you've received a request, but haven't completed it yet (ex, it has been added to a queue).
func StatusBadRequest ¶
For when the *user* has screwed up a request.
func StatusConflict ¶
For when the user asked us to make a change conflicting with the current state of things.
func StatusCreated ¶
For when you've created a document with a new URL.
func StatusFound ¶
For when the document the user requested is currently found at another address, but that may not be the case in the future.
The client may change a POST to a GET request when trying the new location.
func StatusGone ¶
For the resource has been deleted, and will never ever return.
func StatusMethodNotAllowed ¶
func StatusMovedPermanently ¶
For when the document the user requested has permantly moved to a new address.
func StatusMultipleChoices ¶
For when you have document in multiple formats, but you're not sure which the user wants.
func StatusNoContent ¶
For when you've successfully done something, but have no body to return.
func StatusResetContent ¶
The client should reset the form of whatever view it currently has.
func StatusTemporaryRedirect ¶
For when rhe document the user requested has temporarily moved.
The client must repeate the request exactly the same, except for the URL.
Types ¶
This section is empty.