router

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToStopServer = errors.New("failed to stop the server")
)

Functions

This section is empty.

Types

type Context

type Context struct {
	*gin.Context
}

func (*Context) Abort

func (c *Context) Abort(err Error)

func (*Context) AbortWithCode added in v0.12.0

func (c *Context) AbortWithCode(code int, err Error)

func (*Context) AbortWithError

func (c *Context) AbortWithError(statusCode int, err Error)

func (*Context) BadRequest

func (c *Context) BadRequest(err Error)

func (*Context) Conflict

func (c *Context) Conflict(err Error)

func (*Context) Created added in v0.13.0

func (c *Context) Created()

func (*Context) JSON

func (c *Context) JSON(data interface{})

func (*Context) NotFound

func (c *Context) NotFound(err Error)

func (*Context) NotModified added in v0.16.0

func (c *Context) NotModified()

func (*Context) OK

func (c *Context) OK()

func (*Context) ParseBody

func (c *Context) ParseBody(obj interface{}) error

func (*Context) Unauthorized added in v0.16.0

func (c *Context) Unauthorized(err Error)

func (*Context) Unprocessable added in v0.13.0

func (c *Context) Unprocessable(err Error)

type ErrCode

type ErrCode string
const (
	ErrFailedToParseBody ErrCode = "failed_to_parse_body"
)

type Error

type Error struct {
	Code           ErrCode `json:"code"`
	PublicMessage  string  `json:"message,omitempty"`
	PrivateMessage string  `json:"-"`
}

func (Error) Error

func (e Error) Error() string

type Group

type Group struct {
	*gin.RouterGroup
}

func (*Group) Any

func (g *Group) Any(path string, handlers ...HandlerFunc)

func (*Group) DELETE

func (g *Group) DELETE(path string, handlers ...HandlerFunc)

func (*Group) GET

func (g *Group) GET(path string, handlers ...HandlerFunc)

func (*Group) Group

func (g *Group) Group(path string, handlers ...HandlerFunc) *Group

func (*Group) HEAD

func (g *Group) HEAD(path string, handlers ...HandlerFunc)

func (*Group) OPTIONS

func (g *Group) OPTIONS(path string, handlers ...HandlerFunc)

func (*Group) PATCH

func (g *Group) PATCH(path string, handlers ...HandlerFunc)

func (*Group) POST

func (g *Group) POST(path string, handlers ...HandlerFunc)

func (*Group) PUT

func (g *Group) PUT(path string, handlers ...HandlerFunc)

type HandlerFunc

type HandlerFunc func(*Context)

type Router

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

func New

func New() *Router

func (*Router) Any

func (r *Router) Any(path string, handlers ...HandlerFunc)

func (*Router) DELETE

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

func (*Router) GET

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

func (*Router) Group

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

func (*Router) HEAD

func (r *Router) HEAD(path string, handlers ...HandlerFunc)

func (*Router) Handle added in v0.16.0

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

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handlers ...HandlerFunc)

func (*Router) PATCH

func (r *Router) PATCH(path string, handlers ...HandlerFunc)

func (*Router) POST

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

func (*Router) PUT

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

func (*Router) Start

func (r *Router) Start(addr string) error

func (*Router) Stop

func (r *Router) Stop(ctx context.Context) error

Stop gracefully shuts down the server. It will throw ErrFailedToStopServer if the server fails to stop.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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