Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var APIErrorErrorMarshallingHTTPResponse = &APIError{"error_marshalling_http_response", "An internal error occured while generating the response", 500}
Error served when there is an error encoding the provided data into json for a response.
var APIErrorManualMarshalledErrorMarshallingHTTPResponse = "" + "{" + "\"error\":" + "{" + "\"id\":\"" + APIErrorErrorMarshallingHTTPResponse.Id + "\"," + "\"message\":\"" + APIErrorErrorMarshallingHTTPResponse.Message + "\"," + "\"http_code\": " + string(APIErrorErrorMarshallingHTTPResponse.HTTPCode) + "}" + "}"
String representing APIErrorErrorMarshallingHTTPResponse in JSON form
This field is here for use when an error occurs marshalling an HTTPResponse object to send to a client. It was put in this file (Although used elsewhere) so that is is kept up to date with any field changes of APIError.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Id string `json:"id"` Message string `json:"message"` HTTPCode int `json:"http_code"` }
APIError provides detail about an error that occurred while handling an endpoint
IMPORTANT: Update the manual fields below (APIErrorErrorMarshallingHTTPResponse and APIErrorManualMarshalledErrorMarshallingHTTPResponse) if any changes are made to the field or their tags.
type AppContext ¶
AppContext is used to provide stateful application configuration data to stateless endpoint handlers
type AppContextProvider ¶
type AppContextProvider interface {
Ctx() *AppContext
}
type Config ¶
type Config struct { // Google API Client Id GAPIClientId string // URI used in JWTs to identify server JWTServerURI string // Key used to sign JWSs with HS512 JWTHMACKey string }
Config holds application configuration values
type HTTPResponse ¶
type HTTPResponse struct {
Error *APIError `json:"error"`
}
func (*HTTPResponse) Serve ¶
func (r *HTTPResponse) Serve(w http.ResponseWriter) error
Serve HTTPResponse struct as JSON with appropriate HTTP status code.
func (*HTTPResponse) WithError ¶
func (r *HTTPResponse) WithError(id, message string, code int) *HTTPResponse