rx

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Request *http.Request
	Writer  ResponseWriter
	Params  Params

	Keys map[string]any
	// contains filtered or unexported fields
}

func (*Context) Abort

func (c *Context) Abort()

func (*Context) AbortWithError added in v0.0.6

func (c *Context) AbortWithError(err error)

func (*Context) AbortWithJSON

func (c *Context) AbortWithJSON(code int, obj any)

func (*Context) AbortWithStatus

func (c *Context) AbortWithStatus(code int)

func (*Context) Aborted added in v0.0.7

func (c *Context) Aborted() bool

func (*Context) Context added in v0.0.6

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

func (*Context) Get

func (c *Context) Get(key string) (value any, exists bool)

func (*Context) JSON

func (c *Context) JSON(code int, obj any)

func (*Context) Next

func (c *Context) Next()

func (*Context) Param added in v0.0.6

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

func (*Context) Render

func (c *Context) Render(code int, r Render)

func (*Context) Route

func (c *Context) Route() Route

func (*Context) Set

func (c *Context) Set(key string, value any)

func (*Context) Status

func (c *Context) Status(code int)

func (*Context) String

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

func (*Context) UseContext added in v0.0.7

func (c *Context) UseContext(ctx context.Context)

UseContext 使用指定的上下文处理当前请求。 后续中间件和处理函数将使用新的上下文。

type Engine

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

func New

func New() *Engine

func (*Engine) HandleError

func (e *Engine) HandleError(handler ErrorHandler)

func (*Engine) NoRoute

func (e *Engine) NoRoute(handlers ...HandlerFunc)

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*Engine) Use

func (e *Engine) Use(middleware ...HandlerFunc)

func (*Engine) UseRouter added in v0.0.6

func (e *Engine) UseRouter(router Router)

type ErrorHandler

type ErrorHandler func(c *Context, err error)

type HandlerFunc

type HandlerFunc func(c *Context)

func Logger added in v0.0.6

func Logger() HandlerFunc

type HandlersChain

type HandlersChain []HandlerFunc

func CombineHandlers added in v0.0.6

func CombineHandlers(base HandlersChain, handlers ...HandlerFunc) HandlersChain

type Param added in v0.0.6

type Param struct {
	// Key 是规则中声明的参数名,不包含前缀的 : 或 *。
	Key string

	// Value 是输入路径中被该参数捕获到的原始字符串。
	Value string
}

Param 是一次路径匹配得到的单个参数。

type Params added in v0.0.6

type Params []Param

Params 是按规则中参数出现顺序保存的参数列表。

func (Params) ByName added in v0.0.6

func (ps Params) ByName(name string) string

ByName 返回指定名称的参数;不存在时返回空字符串。

func (Params) Get added in v0.0.6

func (ps Params) Get(name string) (string, bool)

Get 返回指定名称的参数。

type Render

type Render interface {
	Render(http.ResponseWriter) error

	ContentType() []string
}

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter
	http.Hijacker
	http.Flusher

	// Status returns the HTTP response status code of the current request.
	Status() int

	// Size returns the number of bytes already written into the response http body.
	// See Written()
	Size() int

	// WriteString writes the string into the response body.
	WriteString(string) (int, error)

	// Written returns true if the response body was already written.
	Written() bool

	// WriteHeaderNow forces to write the http header (status code + headers).
	WriteHeaderNow()

	// Pusher get the http.Pusher for server push
	Pusher() http.Pusher
}

ResponseWriter ...

type Route

type Route interface {
	Path() string
	Handlers() HandlersChain
}

Route 表示 Router 已经匹配到的处理目标。

func NewRoute

func NewRoute(path string, handlers ...HandlerFunc) Route

NewRoute 创建只执行本地处理函数的路由。

type Router added in v0.0.6

type Router interface {
	Match(method string, path string, params Params) (Route, Params, error)
}

Router 负责根据 method 和 path 匹配并返回 Route。

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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