omg

package module
v0.0.0-...-6b9a538 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolHttp  string = "http"
	ProtocolHttps string = "https"
)

Variables

This section is empty.

Functions

func Default404

func Default404(ctx *Context) (string, error)

func UtilsExistsInSlice

func UtilsExistsInSlice(s []string, findValue string) bool

func UtilsGetContentType

func UtilsGetContentType(contentType string, reqUrl string) string

func UtilsToBool

func UtilsToBool(value interface{}) bool

func UtilsToInt

func UtilsToInt(value interface{}) int

func UtilsToString

func UtilsToString(value interface{}) string

Types

type AppContext

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

func (*AppContext) GetPlugin

func (app *AppContext) GetPlugin(pluginName string) (interface{}, error)

func (*AppContext) SetPlugin

func (app *AppContext) SetPlugin(pluginName string, pluginClient interface{})

type Context

type Context struct {
	Req    Request
	Res    Response
	Status int // response status
	Body   []byte
	// contains filtered or unexported fields
}

func (*Context) Get

func (ctx *Context) Get(key string) []string

func (*Context) GetCookie

func (ctx *Context) GetCookie(cookieName string) string

func (*Context) Plugin

func (ctx *Context) Plugin(pluginName string) (interface{}, error)

func (*Context) Redirect

func (ctx *Context) Redirect(target string)

func (*Context) Set

func (ctx *Context) Set(key string, value ...string)

func (*Context) SetCookie

func (ctx *Context) SetCookie(cookieName string, cookieValue string, options map[string]interface{})

func (*Context) SetPlugin

func (ctx *Context) SetPlugin(pluginName string, pluginInstance interface{})

type ContextPlugin

type ContextPlugin struct{}

func (*ContextPlugin) GetContextInstance

func (ctxPlugin *ContextPlugin) GetContextInstance(ctx *Context) interface{}

type Handler

type Handler = func(ctx *Context) (string, error)

type MW

type MW = func(ctx *Context, next Next) (string, error)

type MWWrapper

type MWWrapper = func(ctx *AppContext) MW

type Method

type Method string
const (
	MethodGet  Method = "get"
	MethodPost Method = "post"
	MethodAll  Method = "all"
)

func GetMethod

func GetMethod(method string) Method

type MiddleWareManager

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

func (*MiddleWareManager) Exec

func (mw *MiddleWareManager) Exec(ctx *Context, handler Handler) (string, error)

func (*MiddleWareManager) Use

func (mw *MiddleWareManager) Use(newMw MW)

type Next

type Next = func() (string, error)

type Request

type Request struct {
	Url       string
	Method    Method
	OriginReq *fasthttp.Request
}

type Response

type Response struct {
	Headers   map[string][]string
	Type      string
	OriginRes *fasthttp.Response
}

type RouteItem

type RouteItem struct {
	Path     string
	Level    int
	PurePath string
	MatchReg *regexp.Regexp
	Register []RouteRegister // 多个method
}

func GetRouteItem

func GetRouteItem(path string) RouteItem

type RouteRegister

type RouteRegister struct {
	Method  Method
	Handler Handler
}

type Server

type Server struct {
	Port    string
	Routers []RouteItem
	// contains filtered or unexported fields
}

func New

func New() *Server

func (*Server) Close

func (s *Server) Close() error

func (*Server) Get

func (s *Server) Get(path string, handler Handler) *Server

func (*Server) Handle

func (s *Server) Handle(path string, handler Handler, methods ...Method) *Server

func (*Server) Post

func (s *Server) Post(path string, handler Handler) *Server

func (*Server) Start

func (s *Server) Start(port string, protocol ...string)

func (*Server) Use

func (s *Server) Use(mw MWWrapper) *Server

Directories

Path Synopsis
Package ioc Package ioc
Package ioc Package ioc
mw

Jump to

Keyboard shortcuts

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