router

package module
v0.0.0-...-2582309 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: MIT Imports: 5 Imported by: 7

README

router

gin wrapper to use http.Handler and http.HandlerFunc

example

func HomePage(w http.ResponseWriter, r *http.Request) {
	c := router.ContextW(w)
	...
}

func init() {
	mux := router.New()
	mux.Any("/home.html",
		HomePage)
}

Documentation

Index

Constants

View Source
const (
	LogErrName _logFuncType = iota
	LogInfoName
	LogWarnName
	LogDebugName
)

Variables

This section is empty.

Functions

func AbortError

func AbortError(ctx context.Context, code int, err error)

func ContextW

func ContextW(w http.ResponseWriter) *gin.Context

func DisableDebugging

func DisableDebugging()

func EnableDebugging

func EnableDebugging()

func GetDebugLog

func GetDebugLog(ctx context.Context) logfn.LogFunc

func GetErrLog

func GetErrLog(ctx context.Context) logfn.LogFunc

func GetInfoLog

func GetInfoLog(ctx context.Context) logfn.LogFunc

func GetRequest

func GetRequest(ctx context.Context) *http.Request

func GetWarnLog

func GetWarnLog(ctx context.Context) logfn.LogFunc

func GetWriter

func GetWriter(ctx context.Context) http.ResponseWriter

func GinWrap

func GinWrap(f interface{}) gin.HandlerFunc

func GinWrapC

func GinWrapC(f Handler) gin.HandlerFunc

func GinWrapF

func GinWrapF(f http.HandlerFunc) gin.HandlerFunc

func GinWrapH

func GinWrapH(h http.Handler) gin.HandlerFunc

func NewContextW

func NewContextW(c *gin.Context) *_ContextW

func Param

func Param(ctx context.Context, param string) string

func Redirect

func Redirect(ctx context.Context, code int, path string)

func Wrap

func Wrap(handlers ...interface{}) []gin.HandlerFunc

func WrapC

func WrapC(handlers ...Handler) []gin.HandlerFunc

func WrapF

func WrapF(handlers ...http.HandlerFunc) []gin.HandlerFunc

func WrapH

func WrapH(handlers ...http.Handler) []gin.HandlerFunc

Types

type EngineStd

type EngineStd struct {
	*gin.Engine
}

func New

func New() *EngineStd

func WrapGin

func WrapGin(o *gin.Engine) *EngineStd

func (*EngineStd) Any

func (e *EngineStd) Any(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) AnyC

func (e *EngineStd) AnyC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) AnyF

func (e *EngineStd) AnyF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) AnyH

func (e *EngineStd) AnyH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) DELETE

func (e *EngineStd) DELETE(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) DELETEC

func (e *EngineStd) DELETEC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) DELETEF

func (e *EngineStd) DELETEF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) DELETEH

func (e *EngineStd) DELETEH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) GET

func (e *EngineStd) GET(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) GETC

func (e *EngineStd) GETC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) GETF

func (e *EngineStd) GETF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) GETH

func (e *EngineStd) GETH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) Gin

func (e *EngineStd) Gin() *gin.Engine

func (*EngineStd) HEAD

func (e *EngineStd) HEAD(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) HEADC

func (e *EngineStd) HEADC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) HEADF

func (e *EngineStd) HEADF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) HEADH

func (e *EngineStd) HEADH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) Handle

func (e *EngineStd) Handle(httpMethod, relativePath string, handlers ...interface{}) IRoutesStd

func (interface{})

func (*EngineStd) HandleC

func (e *EngineStd) HandleC(httpMethod, relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) HandleF

func (e *EngineStd) HandleF(httpMethod, relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) HandleH

func (e *EngineStd) HandleH(httpMethod, relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) OPTIONS

func (e *EngineStd) OPTIONS(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) OPTIONSC

func (e *EngineStd) OPTIONSC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) OPTIONSF

func (e *EngineStd) OPTIONSF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) OPTIONSH

func (e *EngineStd) OPTIONSH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) PATCH

func (e *EngineStd) PATCH(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) PATCHC

func (e *EngineStd) PATCHC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) PATCHF

func (e *EngineStd) PATCHF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) PATCHH

func (e *EngineStd) PATCHH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) POST

func (e *EngineStd) POST(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) POSTC

func (e *EngineStd) POSTC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) POSTF

func (e *EngineStd) POSTF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) POSTH

func (e *EngineStd) POSTH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) PUT

func (e *EngineStd) PUT(relativePath string, handlers ...interface{}) IRoutesStd

func (*EngineStd) PUTC

func (e *EngineStd) PUTC(relativePath string, handlers ...Handler) IRoutesStd

func (*EngineStd) PUTF

func (e *EngineStd) PUTF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) PUTH

func (e *EngineStd) PUTH(relativePath string, handlers ...http.Handler) IRoutesStd

func (*EngineStd) Use

func (e *EngineStd) Use(handlers ...interface{}) IRoutesStd

func (*EngineStd) UseC

func (e *EngineStd) UseC(handlers ...Handler) IRoutesStd

func (*EngineStd) UseF

func (e *EngineStd) UseF(handlers ...http.HandlerFunc) IRoutesStd

func (*EngineStd) UseH

func (e *EngineStd) UseH(handlers ...http.Handler) IRoutesStd

type Handler

type Handler func(context.Context)

type IRoutesStd

type IRoutesStd interface {
	Use(handlers ...interface{}) IRoutesStd

	Handle(httpMethod, relativePath string, handlers ...interface{}) IRoutesStd
	Any(relativePath string, handlers ...interface{}) IRoutesStd
	GET(relativePath string, handlers ...interface{}) IRoutesStd
	POST(relativePath string, handlers ...interface{}) IRoutesStd
	DELETE(relativePath string, handlers ...interface{}) IRoutesStd
	PATCH(relativePath string, handlers ...interface{}) IRoutesStd
	PUT(relativePath string, handlers ...interface{}) IRoutesStd
	OPTIONS(relativePath string, handlers ...interface{}) IRoutesStd
	HEAD(relativePath string, handlers ...interface{}) IRoutesStd

	// http.HandlerFunc
	UseF(handlers ...http.HandlerFunc) IRoutesStd

	HandleF(httpMethod, relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	AnyF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	GETF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	POSTF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	DELETEF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	PATCHF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	PUTF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	OPTIONSF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd
	HEADF(relativePath string, handlers ...http.HandlerFunc) IRoutesStd

	// http.Handler
	UseH(handlers ...http.Handler) IRoutesStd

	HandleH(httpMethod, relativePath string, handlers ...http.Handler) IRoutesStd
	AnyH(relativePath string, handlers ...http.Handler) IRoutesStd
	GETH(relativePath string, handlers ...http.Handler) IRoutesStd
	POSTH(relativePath string, handlers ...http.Handler) IRoutesStd
	DELETEH(relativePath string, handlers ...http.Handler) IRoutesStd
	PATCHH(relativePath string, handlers ...http.Handler) IRoutesStd
	PUTH(relativePath string, handlers ...http.Handler) IRoutesStd
	OPTIONSH(relativePath string, handlers ...http.Handler) IRoutesStd
	HEADH(relativePath string, handlers ...http.Handler) IRoutesStd

	// Handler
	UseC(handlers ...Handler) IRoutesStd

	HandleC(httpMethod, relativePath string, handlers ...Handler) IRoutesStd
	AnyC(relativePath string, handlers ...Handler) IRoutesStd
	GETC(relativePath string, handlers ...Handler) IRoutesStd
	POSTC(relativePath string, handlers ...Handler) IRoutesStd
	DELETEC(relativePath string, handlers ...Handler) IRoutesStd
	PATCHC(relativePath string, handlers ...Handler) IRoutesStd
	PUTC(relativePath string, handlers ...Handler) IRoutesStd
	OPTIONSC(relativePath string, handlers ...Handler) IRoutesStd
	HEADC(relativePath string, handlers ...Handler) IRoutesStd
}

type Store

type Store interface {
	Get(k interface{}) (v interface{}, exists bool)
	Set(k, v interface{})
}

func ToStore

func ToStore(c context.Context) Store

Jump to

Keyboard shortcuts

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