Documentation ¶
Index ¶
- Variables
- func ErrInvalidRequest(err error) render.Renderer
- func ErrRender(err error) render.Renderer
- func Handler(s stats.Service) chi.Router
- func NewStatsListResponse(stats []stats.Stat) []render.Renderer
- func ParseQueryParams(next http.Handler) http.Handler
- type ErrResponse
- type StatsListResponse
- type StatsResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
Functions ¶
func ErrInvalidRequest ¶
func NewStatsListResponse ¶
NewStatsListResponse creates a response built from a slice of stats
func ParseQueryParams ¶
ParseQueryParams is a middleware that parses url query parameters passed in as part of the url. It will generate an injection safe SQL 'WHERE' query string and associated slice of values and add this to the context. @TODO: return error if values are missing.
Types ¶
type ErrResponse ¶
type ErrResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message AppCode int64 `json:"code,omitempty"` // application-specific error code ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
type StatsListResponse ¶
type StatsListResponse []*StatsResponse
StatsListResponse represents a response built from a slice of stats
type StatsResponse ¶
StatsResponse is the response payload for the Stats data model.
func NewStatsResponse ¶
func NewStatsResponse(stat stats.Stat) *StatsResponse
NewStatsResponse generates a new stats response
func (*StatsResponse) Render ¶
func (sr *StatsResponse) Render(w http.ResponseWriter, r *http.Request) error
Render satisfies the chi renderer interface
Click to show internal directories.
Click to hide internal directories.