Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( NotFound = makeErrorResponder(http.StatusNotFound) BadRequest = makeErrorResponder(http.StatusBadRequest) BadMethod = makeErrorResponder(http.StatusMethodNotAllowed) InternalError = makeErrorResponder(http.StatusInternalServerError) NotImplemented = makeErrorResponder(http.StatusNotImplemented) Forbidden = makeErrorResponder(http.StatusForbidden) Conflict = makeErrorResponder(http.StatusConflict) )
standard error responses
Functions ¶
Types ¶
type Command ¶
type Command struct { Path string // GET ResponseFunc PUT ResponseFunc POST ResponseFunc DELETE ResponseFunc // can guest GET? GuestOK bool // can non-admin GET? UserOK bool // is this path accessible on the snapd-snap socket? SnapOK bool // contains filtered or unexported fields }
A Command routes a request to an individual per-verb ResponseFUnc
type Daemon ¶
type Daemon struct { Version string // contains filtered or unexported fields }
A Daemon listens for requests and routes them to the right command
type FileResponse ¶
type FileResponse string
A FileResponse 's ServeHTTP method serves the file
func (FileResponse) ServeHTTP ¶
func (f FileResponse) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP from the Response interface
type Meta ¶
type Meta struct { Sources []string `json:"sources,omitempty"` Paging *Paging `json:"paging,omitempty"` SuggestedCurrency string `json:"suggested-currency,omitempty"` Change string `json:"change,omitempty"` }
TODO This is being done in a rush to get the proper external
JSON representation in the API in time for the release. The right code style takes a bit more work and unifies these fields inside resp.
type Response ¶
type Response interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
Response knows how to serve itself, and how to find itself
func AssertResponse ¶
AssertResponse builds a response whose ServerHTTP method serves one or a bundle of assertions.
func AsyncResponse ¶
AsyncResponse builds an "async" response from the given *Task
func EventResponse ¶
func EventResponse(hub *notifications.Hub) Response
EventResponse returns a response whose ServerHTTP method creates a websocket connection used to communicate operation and logging notifications.
func SyncResponse ¶
SyncResponse builds a "sync" response from the given result.
type ResponseFunc ¶
A ResponseFunc handles one of the individual verbs for a method
type ResponseType ¶
type ResponseType string
ResponseType is the response type
const ( ResponseTypeSync ResponseType = "sync" ResponseTypeAsync ResponseType = "async" ResponseTypeError ResponseType = "error" )
"there are three standard return types: Standard return value, Background operation, Error", each returning a JSON object with the following "type" field: