mux

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentDisposition = "Content-Disposition"
	HeaderContentType        = "Content-Type"

	CharsetUTF8 = "charset=utf-8" // CharsetUTF8 utf8 character set

	ApplicationJSON                  = "application/json"
	ApplicationJSONCharsetUTF8       = ApplicationJSON + "; " + CharsetUTF8
	ApplicationJavaScript            = "application/javascript"
	ApplicationJavaScriptCharsetUTF8 = ApplicationJavaScript + "; " + CharsetUTF8
	ApplicationXML                   = "application/xml"
	ApplicationXMLCharsetUTF8        = ApplicationXML + "; " + CharsetUTF8
	ApplicationYAML                  = "application/yaml"
	ApplicationYAMLCharsetUTF8       = ApplicationYAML + "; " + CharsetUTF8

	TextHTML             = "text/html"
	TextHTMLCharsetUTF8  = TextHTML + "; " + CharsetUTF8
	TextPlain            = "text/plain"
	TextPlainCharsetUTF8 = TextPlain + "; " + CharsetUTF8
	TextYAML             = "text/yaml"
	TextYAMLCharsetUTF8  = TextYAML + "; " + CharsetUTF8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) Bind

func (c *Context) Bind(out interface{}) error

func (*Context) Bytes

func (c *Context) Bytes(raw []byte, contentType string, code ...int)

func (*Context) Context

func (c *Context) Context() context.Context

func (*Context) Download

func (c *Context) Download(r *http.Request, path string, name string) error

Download the client is prompted to save the file with provided `name`, name can be empty, in that case name of the file is used.

func (*Context) Error

func (c *Context) Error(message string, code ...int)

Error sends a error response with a status code

func (*Context) File

func (c *Context) File(r *http.Request, path string) error

File sends a response with the content of the file

func (*Context) HTML

func (c *Context) HTML(html string, code ...int)

HTML sends an HTTP response with status code.

func (*Context) HeaderSet

func (c *Context) HeaderSet(key, value string)

func (*Context) JSON

func (c *Context) JSON(i interface{}, code ...int)

JSON sends a JSON response with status code.

func (*Context) JSONIndent

func (c *Context) JSONIndent(i interface{}, prefix string, indent string, code ...int)

JSONIndent sends a JSON response with status code, but it applies prefix and indent to format the output.

func (*Context) JSONP

func (c *Context) JSONP(callback string, i interface{}, code ...int)

JSONP sends a JSONP response with status code. It uses `callback` to construct the JSONP payload.

func (*Context) NoContent

func (c *Context) NoContent()

NoContent sends a response with no body and a status code.

func (*Context) Output

func (c *Context) Output(out interface{})

func (*Context) Plain

func (c *Context) Plain(s string, code ...int)

Plain sends a string response with status code.

func (*Context) Request

func (c *Context) Request() *http.Request

func (*Context) String

func (c *Context) String(raw string, contentType string, code ...int)

func (*Context) Writer

func (c *Context) Writer() http.ResponseWriter

func (*Context) XML

func (c *Context) XML(i interface{}, code ...int)

XML sends an XML response with status code.

func (*Context) XMLIndent

func (c *Context) XMLIndent(i interface{}, prefix string, indent string, code ...int)

XMLIndent sends an XML response with status code, but it applies prefix and indent to format the output.

func (*Context) YAML

func (c *Context) YAML(i interface{}, code ...int)

type HandlerFunc

type HandlerFunc = func(ctx *Context)

type Mux

type Mux struct {
	// contains filtered or unexported fields
}

func New

func New() *Mux

func (*Mux) Handle

func (m *Mux) Handle(method string, pattern string, handler HandlerFunc)

func (*Mux) Handler

func (m *Mux) Handler() http.Handler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL