Documentation
¶
Overview ¶
Package response provides one-liner constructors for HTTP/WebSocket standard responses.
Index ¶
- func Error(id string, err *errcode.Error) *protocol.Response
- func OK(id string, payload any) (*protocol.Response, error)
- func Paginated(id string, page PageResult) (*protocol.Response, error)
- func Updates(id string, updates []protocol.Update) *protocol.Response
- func WriteResponse(w http.ResponseWriter, resp *protocol.Response, err *errcode.Error)
- type PageResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OK ¶
OK returns a success Response with code 0 and the given payload. Returns an error if marshaling fails.
func Paginated ¶
func Paginated(id string, page PageResult) (*protocol.Response, error)
Paginated returns a success Response wrapping a PageResult in the payload. Returns an error if marshaling fails.
func WriteResponse ¶
WriteResponse writes a protocol.Response as JSON to the http.ResponseWriter with the appropriate HTTP status code.
Types ¶
Click to show internal directories.
Click to hide internal directories.