Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHandler ¶
func GetHandler(s *store.Store) http.HandlerFunc
GetHandler get a value by the key.
func NewAPIError ¶
NewAPIError return a new type of APIError.
func StatusHandler ¶
func StatusHandler() http.HandlerFunc
StatusHandler a handler for a status endpoint, simply returns a "200 OK" response.
Types ¶
type APIError ¶
type APIError struct { Message string `json:"error"` HTTPCode int `json:"-"` // contains filtered or unexported fields }
APIError a type of error that includes a friendly error message and a custom HTTP Status code.
type Acknowledged ¶
type Acknowledged struct {
Acknowledged bool `json:"acknowledged"`
}
Acknowledged a simple response for acknowledging various operations.
type ErrResp ¶
type ErrResp struct {
Error string `json:"error"`
}
ErrResp a standard error response.
type JSONHandler ¶
type JSONHandler func(w http.ResponseWriter, r *http.Request) (interface{}, error)
JSONHandler a handler for JSON responses.
func SetHandler ¶
func SetHandler(s *store.Store) JSONHandler
SetHandler set a key/value pair in the store.
func (JSONHandler) SendErrorResponse ¶
func (j JSONHandler) SendErrorResponse(w http.ResponseWriter, r *http.Request, apiError error)
SendErrorResponse send a JSON error response.
func (JSONHandler) ServeHTTP ¶
func (j JSONHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP executes the handler to receive the response and error.
Click to show internal directories.
Click to hide internal directories.