Documentation ¶
Index ¶
Constants ¶
View Source
const ( HeaderContentType = "Content-Type" TypeApplicationJson = "application/json" DefaultHttpStatus = http.StatusOK )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyOption ¶
type BodyOption struct {
// contains filtered or unexported fields
}
func (BodyOption) Apply ¶
func (p BodyOption) Apply(response *Response)
type HeaderOption ¶
type HeaderOption struct {
// contains filtered or unexported fields
}
func (HeaderOption) Apply ¶
func (h HeaderOption) Apply(response *Response)
type JsonBodyOption ¶
type JsonBodyOption struct { Option // contains filtered or unexported fields }
func (JsonBodyOption) Apply ¶
func (jp JsonBodyOption) Apply(response *Response)
type Option ¶
type Option interface {
Apply(response *Response)
}
func WithContentTypeJson ¶
func WithContentTypeJson() Option
WithContentTypeJson tells the Response its content-Type will be "application/json"
func WithHeader ¶
WithHeader adds a header to the Response. Invoke WithHeader as many times as you have headers to set.
func WithJsonBody ¶
WithJsonBody takes an object meant to be translated to JSON inside the response's body and sets the content-type to "application/json"
func WithStatus ¶
type Response ¶
func NewJsonResponse ¶
func NewResponse ¶
NewResponse creates a Response with default attributes: Status=200 Body=empty byte slice Headers=empty hashmap
func (*Response) Write ¶
func (r *Response) Write(w http.ResponseWriter)
Write sends the Response's content to the http.ResponseWriter.
type StatusOption ¶
type StatusOption struct {
// contains filtered or unexported fields
}
func (StatusOption) Apply ¶
func (s StatusOption) Apply(response *Response)
Click to show internal directories.
Click to hide internal directories.