Documentation ¶
Index ¶
- func GenericObjectEndpoint(w http.ResponseWriter, req *http.Request, processorFunc ObjectProcessorFunc, ...)
- func GenericObjectsEndpoint(w http.ResponseWriter, req *http.Request, processorFunc ObjectsProcessorFunc, ...)
- func RequestAlreadyHandled() error
- type ApiMeta
- type ApiResponse
- type ObjectProcessorFunc
- type ObjectsProcessorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenericObjectEndpoint ¶
func GenericObjectEndpoint(w http.ResponseWriter, req *http.Request, processorFunc ObjectProcessorFunc, statuses ...int)
GenericObjectEndpoint takes a function that produces a (result, error) tuple and runs it.
statuses[0] may contain the success status code (optional, defaults to http.StatusOK). statuses[1] may contain the failure status code (optional, defaults to httpStatusInternalServerError).
func GenericObjectsEndpoint ¶
func GenericObjectsEndpoint(w http.ResponseWriter, req *http.Request, processorFunc ObjectsProcessorFunc, statuses ...int)
GenericUserListEndpoint provides automatic pagination.
func RequestAlreadyHandled ¶
func RequestAlreadyHandled() error
Types ¶
type ApiResponse ¶
type ApiResponse struct { Meta ApiMeta `json:"meta,omitempty"` Objects interface{} `json:"objects"` }
func NewApiResponse ¶
func NewApiResponse(objects interface{}, totalCount int) ApiResponse
type ObjectProcessorFunc ¶
type ObjectProcessorFunc func() (object interface{}, err error)
Click to show internal directories.
Click to hide internal directories.