Documentation ¶
Index ¶
Constants ¶
View Source
const ( JSON = "application/json" YAML = "application/yaml" XML = "application/xml" JS = "application/js" TEXT = "text/plain" HTML = "text/html" BINARY = "application/octet-stream" )
Variables ¶
View Source
var DefaultContentType = TEXT
DefaultContentType defines the default content-type for a new response
View Source
var ObjectDataType = JSON
ObjectDataType defines the default content-type for a rich object
Functions ¶
func GetRecommendedContentType ¶
func GetRecommendedContentType(data interface{}) string
GetRecommendedContentType for the given interface
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string
}
type Response ¶
type Response struct { StatusCode int Headers map[string]string // contains filtered or unexported fields }
func NewErrorResponse ¶
Create a new error response
func NewResponse ¶
Creates a basic response
func (*Response) SetContentType ¶
SetContentType sets the content type from the request, normally text/plain.
func (*Response) SetContentTypeFromRequest ¶
SetContentTypeFromRequest reads the `content-type` header from the request and uses that for the response. Returns the new content type.
Click to show internal directories.
Click to hide internal directories.