engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contain

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

func Contains

func Contains(sub string, opts ...HookOpts) *Contain

func (*Contain) Match

func (c *Contain) Match(method, path string) bool

type Context

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

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request) *Context

func (*Context) Abort

func (c *Context) Abort()

func (*Context) AbortWithStatus

func (c *Context) AbortWithStatus(code int)

func (*Context) AjaxError

func (c *Context) AjaxError(code int, message string, data any)

func (*Context) AjaxJson

func (c *Context) AjaxJson(code int, message string, data any)

func (*Context) AjaxSuccess

func (c *Context) AjaxSuccess(message string, data any)

func (*Context) Authorization

func (c *Context) Authorization() string

func (*Context) Cookie

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

func (*Context) Ctx

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

func (*Context) Error

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

func (*Context) IsAborted

func (c *Context) IsAborted() bool

IsAborted returns true if the current context was aborted.

func (*Context) JSON

func (c *Context) JSON(httpCode int, data any)

func (*Context) JSONArgs

func (c *Context) JSONArgs(v schema.ISchema) error

func (*Context) Next

func (c *Context) Next()

func (*Context) NotFound

func (c *Context) NotFound()

func (*Context) PostForm

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

func (*Context) Query

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

func (*Context) QueryArray

func (c *Context) QueryArray(key string) []string

func (*Context) QueryInt

func (c *Context) QueryInt(key string, missing int) int

func (*Context) QueryInt64

func (c *Context) QueryInt64(key string, missing int64) int64

func (*Context) QueryMap

func (c *Context) QueryMap() url.Values

func (*Context) Redirect

func (c *Context) Redirect(code int, url string)

func (*Context) Request

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

func (*Context) Response

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

func (*Context) SetAuthorization

func (c *Context) SetAuthorization(s string)

func (*Context) SetCookie

func (c *Context) SetCookie(key string, value []byte, expired time.Duration)

func (*Context) SetCookieV2

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

func (*Context) SetDomain

func (c *Context) SetDomain(domain string)

func (*Context) SetUserValue

func (c *Context) SetUserValue(key string, value interface{})

func (*Context) String

func (c *Context) String(code int, text string)

func (*Context) UserValue

func (c *Context) UserValue(key string) any

type Engine

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

func New

func New(opts ...IEnginOpt) *Engine

func (*Engine) DELETE

func (e *Engine) DELETE(path string, fn ...HandlerFunc)

func (*Engine) GET

func (e *Engine) GET(path string, fn ...HandlerFunc)

func (*Engine) OPTIONS

func (e *Engine) OPTIONS(path string, fn ...HandlerFunc)

func (*Engine) PATCH

func (e *Engine) PATCH(path string, fn ...HandlerFunc)

func (*Engine) POST

func (e *Engine) POST(path string, fn ...HandlerFunc)

func (*Engine) PUT

func (e *Engine) PUT(path string, fn ...HandlerFunc)

func (*Engine) Rest

func (e *Engine) Rest(path string, rest any)

func (*Engine) Run

func (e *Engine) Run() (err error)

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Engine) SetAddr

func (e *Engine) SetAddr(addr string)

func (*Engine) SetGuard

func (e *Engine) SetGuard(gd Guard)

func (*Engine) SetRest

func (e *Engine) SetRest(path string, rest any)

func (*Engine) Union

func (e *Engine) Union(methods []string, path string, fn ...HandlerFunc)

func (*Engine) Use

func (e *Engine) Use(pos HookPos, matcher IMatcher, fn HandlerFunc)

type Guard

type Guard struct {
	Method      HttpMethod
	Pos         HookPos
	HandlerFunc HandlerFunc
}

func Cors

func Cors(fn HandlerFunc) Guard

type HandlerFunc

type HandlerFunc func(ctx *Context)

type Hook

type Hook struct {
	Pos         HookPos
	HandlerFunc HandlerFunc
	// contains filtered or unexported fields
}

type HookOpts

type HookOpts func(m IMatcher)

type HookPos

type HookPos int
const (
	PosAhead  HookPos = 1
	PosBehind HookPos = 2
)

type HttpMethod

type HttpMethod string
const (
	MethodGet     HttpMethod = "GET"
	MethodHead    HttpMethod = "HEAD"
	MethodPost    HttpMethod = "POST"
	MethodPut     HttpMethod = "PUT"
	MethodPatch   HttpMethod = "PATCH" // RFC 5789
	MethodDelete  HttpMethod = "DELETE"
	MethodConnect HttpMethod = "CONNECT"
	MethodOptions HttpMethod = "OPTIONS"
	MethodTrace   HttpMethod = "TRACE"
)

type IEnginOpt

type IEnginOpt func(e *Engine)

type IHttpCONNECT

type IHttpCONNECT interface {
	CONNECT(ctx *Context)
}

type IHttpDELETE

type IHttpDELETE interface {
	DELETE(ctx *Context)
}

type IHttpGET

type IHttpGET interface {
	GET(ctx *Context)
}

type IHttpHEAD

type IHttpHEAD interface {
	HEAD(ctx *Context)
}

type IHttpOPTIONS

type IHttpOPTIONS interface {
	OPTIONS(ctx *Context)
}

type IHttpPATCH

type IHttpPATCH interface {
	PATCH(ctx *Context)
}

type IHttpPOST

type IHttpPOST interface {
	POST(ctx *Context)
}

type IHttpPUT

type IHttpPUT interface {
	PUT(ctx *Context)
}

type IHttpTRACE

type IHttpTRACE interface {
	TRACE(ctx *Context)
}

type IMatcher

type IMatcher interface {
	Match(method, path string) bool
}

type IRouter

type IRouter interface {
	POST(path string, fn ...HandlerFunc)
	GET(path string, fn ...HandlerFunc)
	PUT(path string, fn ...HandlerFunc)
	DELETE(path string, fn ...HandlerFunc)
	OPTIONS(path string, fn ...HandlerFunc)
	Use(pos HookPos, matcher IMatcher, fn HandlerFunc)
	Rest(path string, rest any)
	Union(methods []string, path string, fn ...HandlerFunc)
	SetGuard(gd Guard)
}

type Identically

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

func Identical

func Identical(path string) *Identically

func (*Identically) Match

func (i *Identically) Match(method, path string) bool

type Pre

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

func Prefix

func Prefix(prefix string, exclusive []string) *Pre

func (*Pre) Match

func (p *Pre) Match(method, path string) bool

type Reg

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

func RegExp

func RegExp(expr string) *Reg

func (*Reg) Match

func (r *Reg) Match(method, path string) bool

type Route

type Route struct {
	Method       string
	Methods      int
	Path         string
	BeforeHooks  []HandlerFunc
	AfterHooks   []HandlerFunc
	HandlerFuncs []HandlerFunc
}

type Routes

type Routes map[string]*Route

Jump to

Keyboard shortcuts

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