sgin

package module
v0.0.0-...-7a4cc94 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 20 Imported by: 0

README

sgin

这是一个 gin 的魔改版本,旨在让其更加简单。

介绍

r := sgin.New(sgin.Config{
    Mode: gin.DebugMode, // 默认值
    // 相当于 LoadHTMLGlob() 或 LoadHTMLFiles()
    Views: []string{"./views/index.tmpl"},
    ErrorHandler: func(c *sgin.Ctx, err error) { // 默认
      code := http.StatusInternalServerError
      var e *Error
      if errors.As(err, &e) && e.Code != 0 {
          code = e.Code
      }
      return c.Status(code).Send(err)
    }
})

r.Run(":8080")

配置是可选的,可传可不传。

处理方法

处理方法的签名是:gin.HandlerFunc, func(*Ctx[, *T]) <error | T> | (int, T) | (T, error)。 处理方法的第二个参数是可选的,它接收任意请求传来的数据。用法如下:

type Request struct {
    Name   string `form:"name" json:"name"`
    Age    string `form:"age" json:"age" binding:"required"`
    Milli  string `header:"milli" json:"milli"`
    uid    string `uri:"uid" json:"uri"`
}

r.Get("/index", func(c *sgin.Ctx, r *Request) error {
    return c.Send(r) // 将 r 当做响应体发送
})

r.Get("/index/v2", func(c *sgin.Ctx) (r *sgin.Response) {
    // 返回原理与 `Send()` 方法相同
    return &sgin.Response{Message: "OK"}
})

Send(any, format ...string) 方法会自动根据请求头 Accept 返回对应类型的数据,也可以指定其他类型发送,如 sgin.FmtJSON

当处理方法返回响应发生错误时,就会调用全局错误处理函数。以下是处理方法支持的返回类型:

  • error | T:返回一个错误或具体的响应;
  • T:返回任意的响应体;
  • (int, T):返回状态码和响应体;
  • (T, error):任意响应体,错误。

此外,如果你还想要为输入绑定更多的额外参数,或是想为某方法单独处理错误:

r.GET("/index", &sgin.Handler{
    Binding: []binding.Binding{sgin.Uri, sgin.Header},
    Fn: func(c *sgin.Ctx, req *Request) error {
        return c.Send(r)
    },
    Error: func(c *sgin.Ctx, err error) error {
        return c.Status(500).Send(err)
    },
})

该处理将添加 uriheader 参数到你的输入 ( req ) 中,并且在发生错误时,错误将回调到该单独错误处理中,而不会再在其他地方调用。

Api

Ctx
  • Args() map[string]any:该方法根据不同的请求方式返回请求参数的集合;

    例如有一个查询请求为 name=xx&age=10,调用 Args() 方法将返回 {"name": "xx", "age": 10},同样的 POST 或 JSON 请求也会返回该 map

    这样我们就可以不再用区分是何种请求方式,直接调用 Args() 就能拿到你想要的数据。其他如 ArgInt()ArgBool()... 方法都是该方法的快捷方式。

  • Send(any, format ...string) 发送响应。

  • SendHTML(string, any)HTML 模板作为响应发送。

  • Set(key string, ...any) any:设置或将值存储在上下文中。

  • Header(key string, ...any) any:设置或将值写入响应头中。此外 sgin 定义了许多枚举来帮助你快速找到某个请求头,例如要获取内容类型:Header(sgin.HeaderContentType)

  • Status(int) *Ctx:设置响应状态码;

  • StatusCode() int:获取响应状态码;

  • Method() string:获取请求方法;

  • Path() string:返回 Request.URL.Path

  • IP() string:返回远程客户端 IP,如果是本机则返回 127.0.0.1;

  • 其他继承自 gin.Context 的方法。

Documentation

Index

Constants

View Source
const (
	FmtJSON   = "JSON"
	FmtXML    = "XML"
	FmtFile   = "File"
	FmtDown   = "Download"
	FmtStatus = "Status"
)
View Source
const (
	MIMETextXML         = "text/xml"
	MIMETextHTML        = "text/html"
	MIMETextPlain       = "text/plain"
	MIMETextJavaScript  = "text/javascript"
	MIMEApplicationXML  = "application/xml"
	MIMEApplicationJSON = "application/json"
	MIMEApplicationForm = "application/x-www-form-urlencoded"
	MIMEOctetStream     = "application/octet-stream"
	MIMEMultipartForm   = "multipart/form-data"

	MIMETextXMLCharsetUTF8         = "text/xml; charset=utf-8"
	MIMETextHTMLCharsetUTF8        = "text/html; charset=utf-8"
	MIMETextPlainCharsetUTF8       = "text/plain; charset=utf-8"
	MIMETextJavaScriptCharsetUTF8  = "text/javascript; charset=utf-8"
	MIMEApplicationXMLCharsetUTF8  = "application/xml; charset=utf-8"
	MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8"
)

MIME types that are commonly used

View Source
const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // RFC 8297

	StatusOK                          = 200 // RFC 9110, 15.3.1
	StatusCreated                     = 201 // RFC 9110, 15.3.2
	StatusAccepted                    = 202 // RFC 9110, 15.3.3
	StatusNonAuthoritativeInformation = 203 // RFC 9110, 15.3.4
	StatusNoContent                   = 204 // RFC 9110, 15.3.5
	StatusResetContent                = 205 // RFC 9110, 15.3.6
	StatusPartialContent              = 206 // RFC 9110, 15.3.7
	StatusMultiStatus                 = 207 // RFC 4918, 11.1
	StatusAlreadyReported             = 208 // RFC 5842, 7.1
	StatusIMUsed                      = 226 // RFC 3229, 10.4.1

	StatusMultipleChoices   = 300 // RFC 9110, 15.4.1
	StatusMovedPermanently  = 301 // RFC 9110, 15.4.2
	StatusFound             = 302 // RFC 9110, 15.4.3
	StatusSeeOther          = 303 // RFC 9110, 15.4.4
	StatusNotModified       = 304 // RFC 9110, 15.4.5
	StatusUseProxy          = 305 // RFC 9110, 15.4.6
	StatusSwitchProxy       = 306 // RFC 9110, 15.4.7 (Unused)
	StatusTemporaryRedirect = 307 // RFC 9110, 15.4.8
	StatusPermanentRedirect = 308 // RFC 9110, 15.4.9

	StatusBadRequest                   = 400 // RFC 9110, 15.5.1
	StatusUnauthorized                 = 401 // RFC 9110, 15.5.2
	StatusPaymentRequired              = 402 // RFC 9110, 15.5.3
	StatusForbidden                    = 403 // RFC 9110, 15.5.4
	StatusNotFound                     = 404 // RFC 9110, 15.5.5
	StatusMethodNotAllowed             = 405 // RFC 9110, 15.5.6
	StatusNotAcceptable                = 406 // RFC 9110, 15.5.7
	StatusProxyAuthRequired            = 407 // RFC 9110, 15.5.8
	StatusRequestTimeout               = 408 // RFC 9110, 15.5.9
	StatusConflict                     = 409 // RFC 9110, 15.5.10
	StatusGone                         = 410 // RFC 9110, 15.5.11
	StatusLengthRequired               = 411 // RFC 9110, 15.5.12
	StatusPreconditionFailed           = 412 // RFC 9110, 15.5.13
	StatusRequestEntityTooLarge        = 413 // RFC 9110, 15.5.14
	StatusRequestURITooLong            = 414 // RFC 9110, 15.5.15
	StatusUnsupportedMediaType         = 415 // RFC 9110, 15.5.16
	StatusRequestedRangeNotSatisfiable = 416 // RFC 9110, 15.5.17
	StatusExpectationFailed            = 417 // RFC 9110, 15.5.18
	StatusTeapot                       = 418 // RFC 9110, 15.5.19 (Unused)
	StatusMisdirectedRequest           = 421 // RFC 9110, 15.5.20
	StatusUnprocessableEntity          = 422 // RFC 9110, 15.5.21
	StatusLocked                       = 423 // RFC 4918, 11.3
	StatusFailedDependency             = 424 // RFC 4918, 11.4
	StatusTooEarly                     = 425 // RFC 8470, 5.2.
	StatusUpgradeRequired              = 426 // RFC 9110, 15.5.22
	StatusPreconditionRequired         = 428 // RFC 6585, 3
	StatusTooManyRequests              = 429 // RFC 6585, 4
	StatusRequestHeaderFieldsTooLarge  = 431 // RFC 6585, 5
	StatusUnavailableForLegalReasons   = 451 // RFC 7725, 3

	StatusInternalServerError           = 500 // RFC 9110, 15.6.1
	StatusNotImplemented                = 501 // RFC 9110, 15.6.2
	StatusBadGateway                    = 502 // RFC 9110, 15.6.3
	StatusServiceUnavailable            = 503 // RFC 9110, 15.6.4
	StatusGatewayTimeout                = 504 // RFC 9110, 15.6.5
	StatusHTTPVersionNotSupported       = 505 // RFC 9110, 15.6.6
	StatusVariantAlsoNegotiates         = 506 // RFC 2295, 8.1
	StatusInsufficientStorage           = 507 // RFC 4918, 11.5
	StatusLoopDetected                  = 508 // RFC 5842, 7.2
	StatusNotExtended                   = 510 // RFC 2774, 7
	StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6
)

HTTP status codes were copied from net/http with the following updates: - Rename StatusNonAuthoritativeInfo to StatusNonAuthoritativeInformation - Add StatusSwitchProxy (306) NOTE: Keep this list in sync with statusMessage

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"
)

HTTP Headers were copied from net/http.

Variables

View Source
var (
	Uri    = _uri{}
	Form   = binding.Form
	JSON   = binding.JSON
	XML    = binding.XML
	TOML   = binding.TOML
	YAML   = binding.YAML
	Header = binding.Header
)
View Source
var (
	ErrBadRequest                   = NewError(StatusBadRequest)                   // 400
	ErrUnauthorized                 = NewError(StatusUnauthorized)                 // 401
	ErrPaymentRequired              = NewError(StatusPaymentRequired)              // 402
	ErrForbidden                    = NewError(StatusForbidden)                    // 403
	ErrNotFound                     = NewError(StatusNotFound)                     // 404
	ErrMethodNotAllowed             = NewError(StatusMethodNotAllowed)             // 405
	ErrNotAcceptable                = NewError(StatusNotAcceptable)                // 406
	ErrProxyAuthRequired            = NewError(StatusProxyAuthRequired)            // 407
	ErrRequestTimeout               = NewError(StatusRequestTimeout)               // 408
	ErrConflict                     = NewError(StatusConflict)                     // 409
	ErrGone                         = NewError(StatusGone)                         // 410
	ErrLengthRequired               = NewError(StatusLengthRequired)               // 411
	ErrPreconditionFailed           = NewError(StatusPreconditionFailed)           // 412
	ErrRequestEntityTooLarge        = NewError(StatusRequestEntityTooLarge)        // 413
	ErrRequestURITooLong            = NewError(StatusRequestURITooLong)            // 414
	ErrUnsupportedMediaType         = NewError(StatusUnsupportedMediaType)         // 415
	ErrRequestedRangeNotSatisfiable = NewError(StatusRequestedRangeNotSatisfiable) // 416
	ErrExpectationFailed            = NewError(StatusExpectationFailed)            // 417
	ErrTeapot                       = NewError(StatusTeapot)                       // 418
	ErrMisdirectedRequest           = NewError(StatusMisdirectedRequest)           // 421
	ErrUnprocessableEntity          = NewError(StatusUnprocessableEntity)          // 422
	ErrLocked                       = NewError(StatusLocked)                       // 423
	ErrFailedDependency             = NewError(StatusFailedDependency)             // 424
	ErrTooEarly                     = NewError(StatusTooEarly)                     // 425
	ErrUpgradeRequired              = NewError(StatusUpgradeRequired)              // 426
	ErrPreconditionRequired         = NewError(StatusPreconditionRequired)         // 428
	ErrTooManyRequests              = NewError(StatusTooManyRequests)              // 429
	ErrRequestHeaderFieldsTooLarge  = NewError(StatusRequestHeaderFieldsTooLarge)  // 431
	ErrUnavailableForLegalReasons   = NewError(StatusUnavailableForLegalReasons)   // 451

	ErrInternalServerError           = NewError(StatusInternalServerError)           // 500
	ErrNotImplemented                = NewError(StatusNotImplemented)                // 501
	ErrBadGateway                    = NewError(StatusBadGateway)                    // 502
	ErrServiceUnavailable            = NewError(StatusServiceUnavailable)            // 503
	ErrGatewayTimeout                = NewError(StatusGatewayTimeout)                // 504
	ErrHTTPVersionNotSupported       = NewError(StatusHTTPVersionNotSupported)       // 505
	ErrVariantAlsoNegotiates         = NewError(StatusVariantAlsoNegotiates)         // 506
	ErrInsufficientStorage           = NewError(StatusInsufficientStorage)           // 507
	ErrLoopDetected                  = NewError(StatusLoopDetected)                  // 508
	ErrNotExtended                   = NewError(StatusNotExtended)                   // 510
	ErrNetworkAuthenticationRequired = NewError(StatusNetworkAuthenticationRequired) // 511
)

Errors

Functions

func DefaultErrorHandler

func DefaultErrorHandler(c *Ctx, err error) error

DefaultErrorHandler 该进程从处理程序返回错误

Types

type AnyHandler

type AnyHandler = any // func(<*gin.Context | *Ctx>[, *T]) <error | T> | (int, T) | (T, error)

type Config

type Config struct {
	Mode         string   // gin.DebugMode | gin.ReleaseMode
	Views        []string // filepath.Glob pattern | []file
	Recovery     func(*Ctx, string)
	ErrorHandler func(*Ctx, error) error
}

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) Arg

func (c *Ctx) Arg(key string, e ...string) string

func (*Ctx) ArgBool

func (c *Ctx) ArgBool(key string) bool

func (*Ctx) ArgInt

func (c *Ctx) ArgInt(key string, e ...int) int

func (*Ctx) ArgInt64

func (c *Ctx) ArgInt64(key string, e ...int64) int64

func (*Ctx) Args

func (c *Ctx) Args() (args map[string]any)

func (*Ctx) Cookie

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

func (*Ctx) GinCtx

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

func (*Ctx) Header

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

func (*Ctx) HeaderOrQuery

func (c *Ctx) HeaderOrQuery(key string) (value string)

func (*Ctx) IP

func (c *Ctx) IP() (ip string)

func (*Ctx) Locals

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

Locals 设置或将值存储在上下文中。

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) Status

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

func (*Ctx) StatusCode

func (c *Ctx) StatusCode() int

type Engine

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

func New

func New(config ...Config) *Engine

func (*Engine) Routes

func (e *Engine) Routes() gin.RoutesInfo

func (*Engine) Run

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

func (*Engine) RunListener

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

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents an error that occurred while handling a request.

func NewError

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

NewError creates a new Error instance with an optional message

func (*Error) Error

func (e *Error) Error() string

type Handler

type Handler struct {
	Binding []binding.Binding
	Fn      AnyHandler
}

type Response

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

func (*Response) OK

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

func (*Response) WithCode

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

func (*Response) WithCount

func (r *Response) WithCount(count int) *Response

func (*Response) WithData

func (r *Response) WithData(data any) *Response

func (*Response) WithMsg

func (r *Response) WithMsg(message any) *Response

func (*Response) WithStatus

func (r *Response) WithStatus(status int) *Response

type Router

type Router interface {
	Use(args ...AnyHandler) Router
	GET(path string, handlers ...AnyHandler) Router
	POST(path string, handlers ...AnyHandler) Router
	Group(path string, handlers ...AnyHandler) Router
	Handle(method, path string, handlers ...AnyHandler) Router
	Static(path, root string) Router
}

type Routers

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

func (*Routers) GET

func (r *Routers) GET(path string, handlers ...AnyHandler) Router

func (*Routers) Group

func (r *Routers) Group(path string, handlers ...AnyHandler) Router

func (*Routers) Handle

func (r *Routers) Handle(method string, path string, handlers ...AnyHandler) Router

func (*Routers) POST

func (r *Routers) POST(path string, handlers ...AnyHandler) Router

func (*Routers) Static

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

func (*Routers) Use

func (r *Routers) Use(args ...AnyHandler) Router

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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