sgin

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 25 Imported by: 0

README

sgin

这是一个 gin 的封装版本,旨在提供更加智能、简洁的 API 开发体验。它通过增强的 Handler 签名、统一的参数绑定和自动化的 OpenAPI 文档生成,让开发者专注于业务逻辑。

安装

go get github.com/baagod/sgin

快速开始

package main

import (
    "github.com/baagod/sgin"
    "github.com/baagod/sgin/oa"
)

func main() {
    // 1. 初始化引擎 (可选配置)
    r := sgin.New(sgin.Config{
        // 开启 OpenAPI 文档支持 (测试功能)
        OpenAPI: oa.New(oa.Config{}), 
    })

    // 2. 定义路由
    r.GET("/", func(c *sgin.Ctx) string {
        return "Hello sgin!"
    })

    // 3. 启动服务
    r.Run(":8080")
}

核心特性

1. 智能 Handler

sgin 支持多种灵活的 Handler 签名,自动处理参数绑定和响应发送。

支持的签名示例:

  • func(*gin.Context) 兼容 gin
  • func(*sgin.Ctx) error
  • func(*sgin.Ctx) (data any, err error)
  • func(*sgin.Ctx, input Struct) (data any, err error)
  • func(*sgin.Ctx, input Struct) (data any)
请求参数绑定

只需在 Handler 的第二个参数定义结构体,sgin 会自动将 URIHeaderQueryFormBody (JSON/XML) 的数据绑定到该结构体上。

type UserReq struct {
    ID    int    `uri:"id" binding:"required"`
    Name  string `form:"name" binding:"required" failtip:"姓名不能为空"`
    Age   int    `form:"age" default:"18"`
    Token string `header:"Authorization"`
}

r.POST("/users/:id", func(c *sgin.Ctx, req UserReq) (map[string]any, error) {
    // req 已自动绑定并校验通过
    return map[string]any{
        "id":   req.ID,
        "name": req.Name,
        "age":  req.Age,
    }, nil
})
统一响应处理

Handler 的返回值会被自动处理:

  • error: 自动调用配置的 ErrorHandler
  • data: 自动根据请求头 Accept 格式化为 JSON, XML 或 Text。

你也可以使用 c.Send() 手动发送:

c.Send("Hello")                 // Text
c.Send(User{}, sgin.FormatJSON) // JSON
c.Send(User{}, sgin.FormatXML)  // 或者手动指定格式
c.Send(err)                     // Error
2. 增强的 Context (sgin.Ctx)

sgin.Ctx 封装了 gin.Context,提供了更便捷的方法:

  • 参数获取: Values() 方法统一获取所有来源的参数(Query, Form, JSON Body 等)。
  • 类型转换: ValueInt("age"), ValueBool("is_admin") 等。
  • 文件处理: ValueFile("file") 获取上传文件。
  • 响应控制: Status(200), SetHeader("Key", "Val")
  • TraceID: 自动生成或传递 X-Request-ID
  • Gin: 返回 *gin.Context
func(c *sgin.Ctx) {
    id := c.ValueInt("id", 0) // 获取参数,默认值为 0
    ip := c.IP()
    traceID := c.TraceID()
}
3. OpenAPI 文档 (测试版)

sgin 可以通过分析 Handler 的输入输出结构体,自动生成 OpenAPI 3.1 文档。

启用方法: 在 sgin.Config 中配置 OpenAPI 字段。

文档自定义: 在路由定义的第一个参数传入 func(*oa.Operation) 来补充文档信息。

type LoginReq struct {
    Username string `json:"username" doc:"用户名"`
    Password string `json:"password" doc:"密码"`
}

// 注册路由时添加文档描述
r.POST("/login", func(op *oa.Operation) {
    op.Summary = "用户登录"
    op.Tags = []string{"Auth"}
}, func(c *sgin.Ctx, req LoginReq) (string, error) {
    return "token-xxx", nil
})

启动后访问 /openapi.yaml 查看生成的规范。

配置

conf := sgin.Config{
    Mode: gin.ReleaseMode, // 运行模式
    // 自定义错误处理
    ErrorHandler: func(c *sgin.Ctx, err error) error {
        return c.Status(500).Send(map[string]any{"error": err.Error()})
    },
    // 自定义日志
    Logger: func(c *sgin.Ctx, msg string, jsonMsg string) bool {
        // 返回 true 使用默认日志输出,false 拦截
        return true
    },
}

Documentation

Index

Constants

View Source
const (
	FormatXML      = "XML"
	FormatJSON     = "JSON"
	FormatText     = "Text"
	FormatUpload   = "Upload"
	FormatDownload = "Download"
)
View Source
const (
	MIMETextXML        = "text/xml"
	MIMETextHTML       = "text/html"
	MIMETextPlain      = "text/plain"
	MIMETextJavaScript = "text/javascript"
	MIMETextCSS        = "text/css"
	MIMETextYAML       = "text/yaml"
	MIMEXML            = "application/xml"
	MIMEJSON           = "application/json"
	MIMEJavaScript     = "application/javascript"
	MIMECBOR           = "application/cbor"
	MIMEForm           = "application/x-www-form-urlencoded"
	MIMEOctetStream    = "application/octet-stream"
	MIMEMultipartForm  = "multipart/form-data"
	MIMEMsgPack        = "application/vnd.msgpack"

	MIMETextXMLUTF8        = "text/xml; charset=utf-8"
	MIMETextHTMLUTF8       = "text/html; charset=utf-8"
	MIMETextPlainUTF8      = "text/plain; charset=utf-8"
	MIMETextJavaScriptUTF8 = "text/javascript; charset=utf-8"
	MIMETextCSSUTF8        = "text/css; charset=utf-8"
	MIMETextYAMLUTF8       = "text/yaml; charset=utf-8"
	MIMEXMLUTF8            = "application/xml; charset=utf-8"
	MIMEJSONUTF8           = "application/json; charset=utf-8"
)

MIME types that are commonly used

View Source
const (
	HeaderAuthorization                      = "Authorization"
	HeaderProxyAuthenticate                  = "Proxy-Authenticate"
	HeaderProxyAuthorization                 = "Proxy-Authorization"
	HeaderWWWAuthenticate                    = "WWW-Authenticate"
	HeaderAge                                = "Age"
	HeaderCacheControl                       = "Cache-Control"
	HeaderClearSiteData                      = "Clear-Site-Data"
	HeaderExpires                            = "Expires"
	HeaderPragma                             = "Pragma"
	HeaderWarning                            = "Warning"
	HeaderAcceptCH                           = "Accept-CH"
	HeaderAcceptCHLifetime                   = "Accept-CH-Lifetime"
	HeaderContentDPR                         = "Content-DPR"
	HeaderDPR                                = "DPR"
	HeaderEarlyData                          = "Early-Data"
	HeaderSaveData                           = "Save-Data"
	HeaderViewportWidth                      = "Viewport-Width"
	HeaderWidth                              = "Width"
	HeaderETag                               = "ETag"
	HeaderIfMatch                            = "If-Match"
	HeaderIfModifiedSince                    = "If-Modified-Since"
	HeaderIfNoneMatch                        = "If-None-Match"
	HeaderIfUnmodifiedSince                  = "If-Unmodified-Since"
	HeaderLastModified                       = "Last-Modified"
	HeaderVary                               = "Vary"
	HeaderConnection                         = "Connection"
	HeaderKeepAlive                          = "Keep-Alive"
	HeaderAccept                             = "Accept"
	HeaderAcceptCharset                      = "Accept-Charset"
	HeaderAcceptEncoding                     = "Accept-Encoding"
	HeaderAcceptLanguage                     = "Accept-Language"
	HeaderCookie                             = "Cookie"
	HeaderExpect                             = "Expect"
	HeaderMaxForwards                        = "Max-Forwards"
	HeaderSetCookie                          = "Set-Cookie"
	HeaderAccessControlAllowCredentials      = "Access-Control-Allow-Credentials"
	HeaderAccessControlAllowHeaders          = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowMethods          = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowOrigin           = "Access-Control-Allow-Origin"
	HeaderAccessControlExposeHeaders         = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge                = "Access-Control-Max-Age"
	HeaderAccessControlRequestHeaders        = "Access-Control-Request-Headers"
	HeaderAccessControlRequestMethod         = "Access-Control-Request-Method"
	HeaderOrigin                             = "Origin"
	HeaderTimingAllowOrigin                  = "Timing-Allow-Origin"
	HeaderXPermittedCrossDomainPolicies      = "X-Permitted-Cross-Domain-Policies"
	HeaderDNT                                = "DNT"
	HeaderTk                                 = "Tk"
	HeaderContentDisposition                 = "Content-Disposition"
	HeaderContentEncoding                    = "Content-Encoding"
	HeaderContentLanguage                    = "Content-Language"
	HeaderContentLength                      = "Content-Length"
	HeaderContentLocation                    = "Content-Location"
	HeaderContentType                        = "Content-Type"
	HeaderForwarded                          = "Forwarded"
	HeaderVia                                = "Via"
	HeaderXForwardedFor                      = "X-Forwarded-For"
	HeaderXForwardedHost                     = "X-Forwarded-Host"
	HeaderXForwardedProto                    = "X-Forwarded-Proto"
	HeaderXForwardedProtocol                 = "X-Forwarded-Protocol"
	HeaderXForwardedSsl                      = "X-Forwarded-Ssl"
	HeaderXUrlScheme                         = "X-Url-Scheme"
	HeaderLocation                           = "Location"
	HeaderFrom                               = "From"
	HeaderHost                               = "Host"
	HeaderReferer                            = "Referer"
	HeaderReferrerPolicy                     = "Referrer-Policy"
	HeaderUserAgent                          = "User-Agent"
	HeaderAllow                              = "Allow"
	HeaderServer                             = "Server"
	HeaderAcceptRanges                       = "Accept-Ranges"
	HeaderContentRange                       = "Content-Range"
	HeaderIfRange                            = "If-Range"
	HeaderRange                              = "Range"
	HeaderContentSecurityPolicy              = "Content-Security-Policy"
	HeaderContentSecurityPolicyReportOnly    = "Content-Security-Policy-Report-Only"
	HeaderCrossOriginResourcePolicy          = "Cross-Origin-Resource-Policy"
	HeaderExpectCT                           = "Expect-CT"
	HeaderPermissionsPolicy                  = "Permissions-Policy"
	HeaderPublicKeyPins                      = "Public-Key-Pins"
	HeaderPublicKeyPinsReportOnly            = "Public-Key-Pins-Report-Only"
	HeaderStrictTransportSecurity            = "Strict-Transport-Security"
	HeaderUpgradeInsecureRequests            = "Upgrade-Insecure-Requests"
	HeaderXContentTypeOptions                = "X-Content-Type-Options"
	HeaderXDownloadOptions                   = "X-Download-Options"
	HeaderXFrameOptions                      = "X-Frame-Options"
	HeaderXPoweredBy                         = "X-Powered-By"
	HeaderXXSSProtection                     = "X-XSS-Protection"
	HeaderLastEventID                        = "Last-Event-ID"
	HeaderNEL                                = "NEL"
	HeaderPingFrom                           = "Ping-From"
	HeaderPingTo                             = "Ping-To"
	HeaderReportTo                           = "Report-To"
	HeaderTE                                 = "TE"
	HeaderTrailer                            = "Trailer"
	HeaderTransferEncoding                   = "Transfer-Encoding"
	HeaderSecWebSocketAccept                 = "Sec-WebSocket-Accept"
	HeaderSecWebSocketExtensions             = "Sec-WebSocket-Extensions"
	HeaderSecWebSocketKey                    = "Sec-WebSocket-Key"
	HeaderSecWebSocketProtocol               = "Sec-WebSocket-Protocol"
	HeaderSecWebSocketVersion                = "Sec-WebSocket-Version"
	HeaderAcceptPatch                        = "Accept-Patch"
	HeaderAcceptPushPolicy                   = "Accept-Push-Policy"
	HeaderAcceptSignature                    = "Accept-Signature"
	HeaderAltSvc                             = "Alt-Svc"
	HeaderDate                               = "Date"
	HeaderIndex                              = "Index"
	HeaderLargeAllocation                    = "Large-Allocation"
	HeaderLink                               = "Link"
	HeaderPushPolicy                         = "Push-Policy"
	HeaderRetryAfter                         = "Retry-After"
	HeaderServerTiming                       = "Server-Timing"
	HeaderSignature                          = "Signature"
	HeaderSignedHeaders                      = "Signed-Headers"
	HeaderSourceMap                          = "SourceMap"
	HeaderUpgrade                            = "Upgrade"
	HeaderXDNSPrefetchControl                = "X-DNS-Prefetch-Control"
	HeaderXPingback                          = "X-Pingback"
	HeaderXRequestID                         = "X-Request-ID"
	HeaderXRequestedWith                     = "X-Requested-With"
	HeaderXRobotsTag                         = "X-Robots-Tag"
	HeaderXUACompatible                      = "X-UA-Compatible"
	HeaderAccessControlAllowPrivateNetwork   = "Access-Control-Allow-Private-Network"
	HeaderAccessControlRequestPrivateNetwork = "Access-Control-Request-Private-Network"
)

HTTP Headers were copied from net/http.

View Source
const CtxKey = "_baa/sgin/ctxkey"

Variables

This section is empty.

Functions

func DefaultErrorHandler

func DefaultErrorHandler(c *Ctx, err error) error

DefaultErrorHandler 默认的错误处理器

func Logger added in v0.0.7

func Logger(c *Ctx)

Logger 返回一个 Gin 中间件,用于打印结构化的 JSON 请求日志。

func Recovery added in v0.0.7

func Recovery(c *Ctx)

Recovery 是一个增强版的错误恢复中间件 它能打印出发生 panic 的具体源代码片段

Types

type Config

type Config struct {
	Mode           string   // gin.DebugMode | gin.ReleaseMode | gin.TestMode
	TrustedProxies []string // gin.SetTrustedProxies
	Recovery       func(*Ctx, string)
	ErrorHandler   func(*Ctx, error) error
	// 日志记录器回调,参数为 [文本] 和 [JSON] 消息,返回 true 输出默认日志。
	Logger  func(*Ctx, string, string) bool
	OpenAPI *oa.OpenAPI
}

type Ctx

type Ctx struct {
	Request *http.Request
	Writer  gin.ResponseWriter
	Params  gin.Params
	Keys    map[string]any
	// contains filtered or unexported fields
}

func (*Ctx) Content added in v0.0.7

func (c *Ctx) Content(value string) *Ctx

func (*Ctx) Cookie

func (c *Ctx) Cookie(name string) (string, error)

func (*Ctx) Get added in v0.0.7

func (c *Ctx) Get(key string, value ...any) any

Get 设置或将值存储到上下文

func (*Ctx) Gin added in v0.0.7

func (c *Ctx) Gin() *gin.Context

Gin 返回底层的 *gin.Context

func (*Ctx) Header

func (c *Ctx) Header(key string, value ...string) string

Header 获取 HTTP 请求头的值,如果不存在则返回可选的默认值。

func (*Ctx) IP

func (c *Ctx) IP() string

func (*Ctx) Method

func (c *Ctx) Method() string

func (*Ctx) Next

func (c *Ctx) Next() error

func (*Ctx) Param

func (c *Ctx) Param(key string) string

func (*Ctx) Path

func (c *Ctx) Path(full ...bool) string

func (*Ctx) RawBody

func (c *Ctx) RawBody() (body []byte)

func (*Ctx) SaveFile

func (c *Ctx) SaveFile(file *multipart.FileHeader, dst string) error

func (*Ctx) Send

func (c *Ctx) Send(body any, format ...string) error

func (*Ctx) SendHTML

func (c *Ctx) SendHTML(name string, data any) error

func (*Ctx) SetCookie

func (c *Ctx) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)

func (*Ctx) SetHeader

func (c *Ctx) SetHeader(key string, value string) *Ctx

func (*Ctx) Status

func (c *Ctx) Status(code int) *Ctx

func (*Ctx) StatusCode

func (c *Ctx) StatusCode() int

func (*Ctx) TraceID added in v0.0.7

func (c *Ctx) TraceID() string

TraceID 获取当前请求的 [跟踪ID]

func (*Ctx) Value added in v0.0.7

func (c *Ctx) Value(key string, def ...string) string

Value 获取请求参数

func (*Ctx) ValueAny added in v0.0.7

func (c *Ctx) ValueAny(key string, def ...any) any

ValueAny 获取原始类型的参数值

func (*Ctx) ValueBool added in v0.0.7

func (c *Ctx) ValueBool(key string, def ...any) bool

func (*Ctx) ValueFile added in v0.0.7

func (c *Ctx) ValueFile(key string) (*multipart.FileHeader, error)

ValueFile 获取上传的文件

func (*Ctx) ValueFloat64 added in v0.0.7

func (c *Ctx) ValueFloat64(key string, def ...any) float64

func (*Ctx) ValueInt added in v0.0.7

func (c *Ctx) ValueInt(key string, def ...any) int

func (*Ctx) ValueInt64 added in v0.0.7

func (c *Ctx) ValueInt64(key string, def ...any) int64

func (*Ctx) Values added in v0.0.7

func (c *Ctx) Values() map[string]any

Values 获取所有参数 (Body 覆盖 Query)

type Engine

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

func New

func New(config ...Config) *Engine

func (*Engine) Run

func (e *Engine) Run(addr string, certfile ...string) (err error)

Run 将路由器连接到 http.Server 并开始监听和提供 HTTP[S] 请求

提供 cert 和 key 文件路径作为 certfile 参数,可开启 HTTPS 服务。

func (*Engine) RunListener added in v0.0.7

func (e *Engine) RunListener(listener net.Listener) (err error)

RunListener 将路由器连接到 http.Server, 并开始通过指定的 listener 监听和提供 HTTP 请求。

type Error

type Error struct {
	Code    int
	Message string
}

Error 是 APIError 的默认实现

func ErrBadGateway

func ErrBadGateway(msg ...string) *Error

ErrBadGateway 502

func ErrBadRequest

func ErrBadRequest(msg ...string) *Error

ErrBadRequest 400

func ErrConflict

func ErrConflict(msg ...string) *Error

ErrConflict 409

func ErrEntityTooLarge added in v0.0.8

func ErrEntityTooLarge(msg ...string) *Error

ErrEntityTooLarge 413

func ErrExpectationFailed

func ErrExpectationFailed(msg ...string) *Error

ErrExpectationFailed 417

func ErrFailedDependency

func ErrFailedDependency(msg ...string) *Error

ErrFailedDependency 424

func ErrForbidden

func ErrForbidden(msg ...string) *Error

ErrForbidden 403

func ErrGatewayTimeout

func ErrGatewayTimeout(msg ...string) *Error

ErrGatewayTimeout 504

func ErrGone

func ErrGone(msg ...string) *Error

ErrGone 410

func ErrHTTPVersionNotSupported

func ErrHTTPVersionNotSupported(msg ...string) *Error

ErrHTTPVersionNotSupported 505

func ErrHeaderFieldsTooLarge added in v0.0.8

func ErrHeaderFieldsTooLarge(msg ...string) *Error

ErrHeaderFieldsTooLarge 431

func ErrInsufficientStorage

func ErrInsufficientStorage(msg ...string) *Error

ErrInsufficientStorage 507

func ErrInternalServerError

func ErrInternalServerError(msg ...string) *Error

ErrInternalServerError 500

func ErrLengthRequired

func ErrLengthRequired(msg ...string) *Error

ErrLengthRequired 411

func ErrLocked

func ErrLocked(msg ...string) *Error

ErrLocked 423

func ErrLoopDetected

func ErrLoopDetected(msg ...string) *Error

ErrLoopDetected 508

func ErrMethodNotAllowed

func ErrMethodNotAllowed(msg ...string) *Error

ErrMethodNotAllowed 405

func ErrMisdirectedRequest

func ErrMisdirectedRequest(msg ...string) *Error

ErrMisdirectedRequest 421

func ErrNetworkAuthenticationRequired

func ErrNetworkAuthenticationRequired(msg ...string) *Error

ErrNetworkAuthenticationRequired 511

func ErrNotAcceptable

func ErrNotAcceptable(msg ...string) *Error

ErrNotAcceptable 406

func ErrNotExtended

func ErrNotExtended(msg ...string) *Error

ErrNotExtended 510

func ErrNotFound

func ErrNotFound(msg ...string) *Error

ErrNotFound 404

func ErrNotImplemented

func ErrNotImplemented(msg ...string) *Error

ErrNotImplemented 501

func ErrPaymentRequired

func ErrPaymentRequired(msg ...string) *Error

ErrPaymentRequired 402

func ErrPreconditionFailed

func ErrPreconditionFailed(msg ...string) *Error

ErrPreconditionFailed 412

func ErrPreconditionRequired

func ErrPreconditionRequired(msg ...string) *Error

ErrPreconditionRequired 428

func ErrProxyAuthRequired

func ErrProxyAuthRequired(msg ...string) *Error

ErrProxyAuthRequired 407

func ErrRangeNotSatisfiable added in v0.0.8

func ErrRangeNotSatisfiable(msg ...string) *Error

ErrRangeNotSatisfiable 416

func ErrServiceUnavailable

func ErrServiceUnavailable(msg ...string) *Error

ErrServiceUnavailable 503

func ErrTeapot

func ErrTeapot(msg ...string) *Error

ErrTeapot 418

func ErrTimeout added in v0.0.8

func ErrTimeout(msg ...string) *Error

ErrTimeout 408

func ErrTooEarly

func ErrTooEarly(msg ...string) *Error

ErrTooEarly 425

func ErrTooManyRequests

func ErrTooManyRequests(msg ...string) *Error

ErrTooManyRequests 429

func ErrURITooLong added in v0.0.8

func ErrURITooLong(msg ...string) *Error

ErrURITooLong 414

func ErrUnauthorized

func ErrUnauthorized(msg ...string) *Error

ErrUnauthorized 401

func ErrUnavailableForLegalReasons

func ErrUnavailableForLegalReasons(msg ...string) *Error

ErrUnavailableForLegalReasons 451

func ErrUnprocessableEntity

func ErrUnprocessableEntity(msg ...string) *Error

ErrUnprocessableEntity 422

func ErrUnsupportedMediaType

func ErrUnsupportedMediaType(msg ...string) *Error

ErrUnsupportedMediaType 415

func ErrUpgradeRequired

func ErrUpgradeRequired(msg ...string) *Error

ErrUpgradeRequired 426

func ErrVariantAlsoNegotiates

func ErrVariantAlsoNegotiates(msg ...string) *Error

ErrVariantAlsoNegotiates 506

func NewError

func NewError(code int, msg ...string) *Error

NewError 创建一个新的 Error 如果没有提供消息,将使用 http.StatusText(code) 作为默认消息

func NotModified added in v0.0.8

func NotModified(msg ...string) *Error

NotModified 304

func (*Error) Error

func (e *Error) Error() string

type Handler

type Handler any // gin.HandlerFunc | func(*sgin.Ctx[, Input]) T | (T, error)

type IRouter added in v0.0.7

type IRouter interface {
	Use(...Handler) IRouter
	GET(string, ...Handler) IRouter
	POST(string, ...Handler) IRouter
	PUT(string, ...Handler) IRouter
	DELETE(string, ...Handler) IRouter
	Group(string, ...Handler) IRouter
	Handle(method, path string, handlers ...Handler) IRouter
	Static(path, root string) IRouter
}

type Response

type Response struct {
	Event   string `json:"event"`
	Status  int    `json:"status"`
	Code    int    `json:"code"`
	Count   int    `json:"count"`
	Message string `json:"msg"`
	Data    any    `json:"data"`
}

func (*Response) Failed added in v0.0.4

func (r *Response) Failed(data ...any) *Response

Failed 设置失败 (status=0) 数据

func (*Response) OK added in v0.0.4

func (r *Response) OK(data ...any) *Response

OK 设置成功 (status=1) 数据

func (*Response) SetCode

func (r *Response) SetCode(code any) *Response

SetCode 设置 code

func (*Response) SetEvent

func (r *Response) SetEvent(event string) *Response

SetEvent 设置事件

func (*Response) SetMessage

func (r *Response) SetMessage(msg any) *Response

SetMessage 设置消息

func (*Response) SetStatus

func (r *Response) SetStatus(status any, code ...any) *Response

SetStatus 设置 status, code

type Router

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

func (*Router) DELETE added in v0.0.6

func (r *Router) DELETE(path string, handlers ...Handler) IRouter

func (*Router) GET

func (r *Router) GET(path string, handlers ...Handler) IRouter

func (*Router) Group

func (r *Router) Group(path string, handlers ...Handler) IRouter

func (*Router) Handle

func (r *Router) Handle(method, path string, handlers ...Handler) IRouter

func (*Router) POST

func (r *Router) POST(path string, handlers ...Handler) IRouter

func (*Router) PUT added in v0.0.6

func (r *Router) PUT(path string, handlers ...Handler) IRouter

func (*Router) Static

func (r *Router) Static(path, root string) IRouter

func (*Router) Use

func (r *Router) Use(args ...Handler) IRouter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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