serv

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: MIT Imports: 14 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File added in v1.0.6

func File(path string, filename string)

func LoadTemplates

func LoadTemplates(dir string)

func RegMethod

func RegMethod(method string, fn interface{})

func Register

func Register(method string, path string, fn Handler)

func RegisterJsonRPC

func RegisterJsonRPC(url string)

func SetErrorHandler added in v1.0.1

func SetErrorHandler(fn ErrorHandler)

func SetLogger

func SetLogger(l Logger)

func SetLongQueryHandler

func SetLongQueryHandler(delta time.Duration, fn LongQueryHandler)

func SetUID

func SetUID(enable bool)

func Start

func Start(addr string) error

func Static added in v1.0.3

func Static(prefix string, dir string)

Types

type Context

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

func (*Context) BasicAuth

func (c *Context) BasicAuth() (string, string, bool)

func (*Context) Body

func (c *Context) Body() io.ReadCloser

func (*Context) BodyJson

func (c *Context) BodyJson(res interface{}) error

func (*Context) Cookie

func (c *Context) Cookie(name string) string

func (*Context) FormValue

func (c *Context) FormValue(name string) string

func (*Context) FormValueBool

func (c *Context) FormValueBool(name string) bool

func (*Context) FormValueFloat

func (c *Context) FormValueFloat(name string) float64

func (*Context) FormValueInt

func (c *Context) FormValueInt(name string) int

func (*Context) FormValueInt64

func (c *Context) FormValueInt64(name string) int64

func (*Context) GetContentType

func (c *Context) GetContentType() string

func (*Context) GetHeader

func (c *Context) GetHeader(key string) string

func (*Context) Method

func (c *Context) Method() string

func (*Context) Param

func (c *Context) Param(name string) string

func (*Context) ParamBool

func (c *Context) ParamBool(name string) bool

func (*Context) ParamFloat

func (c *Context) ParamFloat(name string) float64

func (*Context) ParamInt

func (c *Context) ParamInt(name string) int

func (*Context) ParamInt64

func (c *Context) ParamInt64(name string) int64

func (*Context) Query

func (c *Context) Query(name string) string

func (*Context) QueryBool

func (c *Context) QueryBool(name string) bool

func (*Context) QueryFloat

func (c *Context) QueryFloat(name string) float64

func (*Context) QueryInt

func (c *Context) QueryInt(name string) int

func (*Context) QueryInt64

func (c *Context) QueryInt64(name string) int64

func (*Context) RemoteAddr

func (c *Context) RemoteAddr() string

func (*Context) Render

func (c *Context) Render(tmpl string, vars map[string]interface{})

func (*Context) RenderStr

func (c *Context) RenderStr(tmpl string, vars map[string]interface{})

func (*Context) RequestPath added in v1.0.2

func (c *Context) RequestPath() string

func (*Context) RequestURI added in v1.0.2

func (c *Context) RequestURI() string

func (*Context) SetContentType

func (c *Context) SetContentType(value string)

func (*Context) SetCookie

func (c *Context) SetCookie(cookie *http.Cookie)

func (*Context) SetHeader

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

func (*Context) StandardError

func (c *Context) StandardError(code int)

func (*Context) Write

func (c *Context) Write(data []byte)

func (*Context) WriteHeader

func (c *Context) WriteHeader(code int)

func (*Context) WriteJson

func (c *Context) WriteJson(v interface{})

func (*Context) WriteRedirect

func (c *Context) WriteRedirect(dest string)

func (*Context) WriteString

func (c *Context) WriteString(txt string)

type ErrorHandler added in v1.0.1

type ErrorHandler func(error)

type Handler

type Handler func(c *Context)

type LogData

type LogData struct {
	Method     string
	Addr       string
	Auth       string
	RequestURL string
	StatusCode int
	Seconds    float64
	Referer    string
	UserAgent  string
	UID        string
}

type Logger

type Logger func(*LogData)

type LongQueryHandler

type LongQueryHandler func(delta time.Duration, c *Context)

type Params

type Params map[string]string

func (Params) GetBool

func (p Params) GetBool(name string) bool

func (Params) GetFloat

func (p Params) GetFloat(name string) float64

func (Params) GetInt

func (p Params) GetInt(name string) int

func (Params) GetInt64

func (p Params) GetInt64(name string) int64

func (Params) GetString

func (p Params) GetString(name string) string

type Query

type Query map[string][]string

func (Query) GetBool

func (p Query) GetBool(name string) bool

func (Query) GetFloat

func (p Query) GetFloat(name string) float64

func (Query) GetInt

func (p Query) GetInt(name string) int

func (Query) GetInt64

func (p Query) GetInt64(name string) int64

func (Query) GetString

func (p Query) GetString(name string) string

Jump to

Keyboard shortcuts

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