Documentation ¶
Index ¶
- func ResolveCallback(req *http.Request) string
- func ResolveContentType(req *http.Request) string
- func ResolveFormat(req *http.Request) string
- func ResolvePrint(req *http.Request) bool
- func Serve(listener net.Listener, handler http.Handler, proto_name string, ...)
- type AcceptLanguage
- type AcceptLanguages
- type BinaryResult
- type ContentDisposition
- type Controller
- func (r *Controller) Binary(name string, rd io.Reader, size int64)
- func (r *Controller) File(path string)
- func (r *Controller) Html(html string)
- func (r *Controller) Json(data interface{})
- func (r *Controller) JsonError(status int, err error)
- func (r *Controller) Read(content_type string, rd io.Reader, sz int64)
- func (r *Controller) Redirect(uri string, query string)
- func (r *Controller) Template(t template.Template, data interface{})
- func (r *Controller) Text(text string)
- func (r *Controller) TextError(status int, err error)
- func (r *Controller) Xml(data interface{})
- type HtmlResult
- type JsonErrorResult
- type JsonResult
- type ReaderResult
- type RedirectResult
- type Request
- func (r *Request) Data() io.ReadCloser
- func (r *Request) JsonData(data interface{}) error
- func (r *Request) MethodToLower() string
- func (r *Request) Param(name string) string
- func (r *Request) Params(name string) []string
- func (r *Request) Suffix() string
- func (r *Request) TrimSuffixURI(suffix string) string
- func (r *Request) URI() string
- type Response
- type Result
- type TemplateResult
- type TextErrorResult
- type TextResult
- type XmlResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveCallback ¶
func ResolveContentType ¶
Get the content type. e.g. From "multipart/form-data; boundary=--" to "multipart/form-data" If none is specified, returns "text/html" by default.
func ResolveFormat ¶
ResolveFormat maps the request's Accept MIME type declaration to a Request.Format attribute, specifically "html", "xml", "json", or "txt", returning a default of "html" when Accept header cannot be mapped to a value above.
func ResolvePrint ¶
Types ¶
type AcceptLanguage ¶
AcceptLanguage is a single language from the Accept-Language HTTP header.
type AcceptLanguages ¶
type AcceptLanguages []AcceptLanguage
AcceptLanguages is collection of sortable AcceptLanguage instances.
func ResolveAcceptLanguage ¶
func ResolveAcceptLanguage(req *http.Request) AcceptLanguages
ResolveAcceptLanguage returns a sorted list of Accept-Language header values.
The results are sorted using the quality defined in the header for each language range with the most qualified language range as the first element in the slice.
See the HTTP header fields specification (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4) for more details.
func (AcceptLanguages) Len ¶
func (al AcceptLanguages) Len() int
func (AcceptLanguages) Less ¶
func (al AcceptLanguages) Less(i, j int) bool
func (AcceptLanguages) String ¶
func (al AcceptLanguages) String() string
func (AcceptLanguages) Swap ¶
func (al AcceptLanguages) Swap(i, j int)
type BinaryResult ¶
type BinaryResult struct { Reader io.Reader Name string Length int64 Delivery ContentDisposition ModTime time.Time }
func (BinaryResult) Apply ¶
func (r BinaryResult) Apply(req *Request, resp *Response)
type ContentDisposition ¶
type ContentDisposition string
var ( Attachment ContentDisposition = "attachment" Inline ContentDisposition = "inline" )
type Controller ¶
func NewController ¶
func NewController(request *Request, response *Response) *Controller
func (*Controller) File ¶
func (r *Controller) File(path string)
func (*Controller) Html ¶
func (r *Controller) Html(html string)
func (*Controller) Json ¶
func (r *Controller) Json(data interface{})
func (*Controller) JsonError ¶
func (r *Controller) JsonError(status int, err error)
func (*Controller) Redirect ¶
func (r *Controller) Redirect(uri string, query string)
func (*Controller) Template ¶
func (r *Controller) Template(t template.Template, data interface{})
func (*Controller) Text ¶
func (r *Controller) Text(text string)
func (*Controller) TextError ¶
func (r *Controller) TextError(status int, err error)
func (*Controller) Xml ¶
func (r *Controller) Xml(data interface{})
type HtmlResult ¶
type HtmlResult struct {
// contains filtered or unexported fields
}
func (HtmlResult) Apply ¶
func (r HtmlResult) Apply(req *Request, resp *Response)
type JsonErrorResult ¶
type JsonErrorResult struct {
// contains filtered or unexported fields
}
func (JsonErrorResult) Apply ¶
func (r JsonErrorResult) Apply(req *Request, resp *Response)
type JsonResult ¶
type JsonResult struct {
// contains filtered or unexported fields
}
func (JsonResult) Apply ¶
func (r JsonResult) Apply(req *Request, resp *Response)
type ReaderResult ¶
type ReaderResult struct {
// contains filtered or unexported fields
}
func (ReaderResult) Apply ¶
func (r ReaderResult) Apply(req *Request, resp *Response)
type RedirectResult ¶
type RedirectResult struct {
// contains filtered or unexported fields
}
func (RedirectResult) Apply ¶
func (r RedirectResult) Apply(req *Request, resp *Response)
type Request ¶
type Request struct { *http.Request ContentType string Format string // "html", "xml", "json", or "txt" Pretty bool Callback string AcceptLanguages AcceptLanguages Locale string ResultErr error }
func NewRequest ¶
func (*Request) Data ¶
func (r *Request) Data() io.ReadCloser
func (*Request) MethodToLower ¶
func (*Request) TrimSuffixURI ¶
type Response ¶
type Response struct { Status int ContentType string Out http.ResponseWriter }
func NewResponse ¶
func NewResponse(w http.ResponseWriter) *Response
func (*Response) WriteHeader ¶
Write the header (for now, just the status code). The status may be set directly by the application (c.Response.Status = 501). if it isn't, then fall back to the provided status code.
type TemplateResult ¶
type TemplateResult struct {
// contains filtered or unexported fields
}
func (TemplateResult) Apply ¶
func (r TemplateResult) Apply(req *Request, resp *Response)
type TextErrorResult ¶
type TextErrorResult struct {
// contains filtered or unexported fields
}
func (TextErrorResult) Apply ¶
func (r TextErrorResult) Apply(req *Request, resp *Response)
This method is used when the template loader or error template is not available.
type TextResult ¶
type TextResult struct {
// contains filtered or unexported fields
}
func (TextResult) Apply ¶
func (r TextResult) Apply(req *Request, resp *Response)