web

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultVersion uint64 = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller added in v1.1.0

type Caller func(*Context) error

Caller ...

type ConfigItem

type ConfigItem struct {
	Addr         string        `yaml:"addr" json:"addr"`
	ReadTimeout  time.Duration `yaml:"read_timeout" json:"read_timeout"`
	WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout"`
	IdleTimeout  time.Duration `yaml:"idle_timeout" json:"idle_timeout"`
}

ConfigItem ...

type Context

type Context struct {
	Writer http.ResponseWriter
	Reader *http.Request
}

Context ...

func (*Context) Decode

func (c *Context) Decode(model interface{}, call Decoder) error

Decode ...

func (*Context) GetCookies

func (c *Context) GetCookies() map[string]*http.Cookie

GetCookies ...

func (*Context) JSON added in v1.2.0

func (c *Context) JSON(code int, model json.Marshaler, heads Headers) error

JSON ...

func (*Context) Redirect

func (c *Context) Redirect(url string) error

Redirect ...

func (*Context) SetCookie

func (c *Context) SetCookie(key, value string, ttl time.Duration)

SetCookie ...

func (*Context) Version added in v1.2.0

func (c *Context) Version() uint64

Version ...

func (*Context) Write added in v1.1.0

func (c *Context) Write(code int, body []byte, heads Headers) error

Write ...

type Debug

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

Debug ...

func NewCustomDebug

func NewCustomDebug(conf ConfigItem, log logger.Logger) *Debug

NewCustomDebug ...

func NewDebug

func NewDebug(conf *DebugConfig, log logger.Logger) *Debug

NewDebug ...

func (*Debug) Down

func (d *Debug) Down() error

Down ...

func (*Debug) Handlers

func (d *Debug) Handlers() []Handler

Handlers ...

func (*Debug) Up

func (d *Debug) Up() error

Up ...

type DebugConfig

type DebugConfig struct {
	Debug ConfigItem `yaml:"debug" json:"debug"`
}

DebugConfig ...

type Decoder added in v1.1.0

type Decoder func(data []byte, v interface{}) error

Decoder ...

type Encoder added in v1.1.0

type Encoder func(v interface{}) ([]byte, error)

Encoder ...

type HTTPConfig

type HTTPConfig struct {
	HTTP ConfigItem `yaml:"http" json:"http"`
}

HTTPConfig ...

type Handler

type Handler struct {
	Method     []string
	Path       string
	Call       VerCaller
	Middleware MiddlewareCaller
}

Handler ...

type Headers

type Headers map[string]string

Headers ...

type MiddlewareCaller added in v1.1.0

type MiddlewareCaller func(*Context) (int, error)

MiddlewareCaller ...

type Route

type Route struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Route ...

func (*Route) AddRoutes added in v1.1.0

func (o *Route) AddRoutes(handlers ...Handler)

AddRoutes ...

func (*Route) InjectRoutes added in v1.1.0

func (o *Route) InjectRoutes(mod RouteInjector)

InjectRoutes ...

func (*Route) ServeHTTP added in v1.1.0

func (o *Route) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP ...

type RouteInjector added in v1.1.0

type RouteInjector interface {
	Handlers() []Handler
}

RouteInjector ...

type RouteItem added in v1.1.0

type RouteItem struct {
	Call       VerCaller
	Middleware MiddlewareCaller
}

RouteItem ...

type Router

type Router interface {
	AddRoutes(handlers ...Handler)
	InjectRoutes(mod RouteInjector)
}

Router ...

type Server

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

Server ...

func NewCustomServer

func NewCustomServer(conf ConfigItem, log logger.Logger) *Server

NewCustomServer ...

func NewServer

func NewServer(conf *HTTPConfig, log logger.Logger) *Server

NewServer ...

func (*Server) Down

func (s *Server) Down() error

Down ...

func (*Server) Router

func (s *Server) Router() Router

Router ...

func (*Server) Up

func (s *Server) Up() error

Up ...

type VerCaller added in v1.2.0

type VerCaller map[uint64]Caller

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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