core

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugMode indicates gin mode is debug.
	DebugMode = "debug"
	// ReleaseMode indicates gin mode is release.
	ReleaseMode = "release"
	// TestMode indicates gin mode is test.
	TestMode = "test"
)

Variables

This section is empty.

Functions

func DebugPrintRoute

func DebugPrintRoute(httpMethod, absolutePath, _ string, _ int)

DebugPrintRoute defined TODO

func Dir

func Dir(root string, listDirectory bool) http.FileSystem

Dir defined TODO

func IsDebugging

func IsDebugging() bool

IsDebugging returns true if the framework is running in debug mode.

func LastChar

func LastChar(str string) uint8

LastChar defined

func SetHandler

func SetHandler(e Handler)

SetHandler defined TODO

func SetMode

func SetMode(value string)

SetMode sets gin mode according to input string.

Types

type Context

type Context interface {
	// Set/Get is used to store a new key/value pair exclusively for this context.
	Set(string, interface{})
	Get(string) interface{}

	// Next
	Next()
	Abort()

	// /user/:id
	Param(string) string

	// /path?id=1234&name=Manu&value=
	Query(key string) string

	// parsed multipart form, including file uploads
	MultipartForm() (*multipart.Form, error)

	// http header
	Header(key, value string)
	GetHeader(key string) string

	// return stream data.
	ShouldBindWith(interface{}) error
	GetRawData() ([]byte, error)

	// Set-Cookie header to the ResponseWriter's headers
	SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
	Cookie(name string) (string, error)

	// render reponse
	HTML(io.Reader, ...interface{})
	XML(io.Reader, ...interface{})
	File(io.Reader, string, ...interface{})
	String(string, ...interface{})

	// net/http
	Request() *http.Request
	SetRequest(r *http.Request)

	ResponseWriter() http.ResponseWriter

	// context
	Deadline() (time.Time, bool)
	Done() <-chan struct{}
	Err() error
	Value(interface{}) interface{}

	// std reponse json
	JSON(code int, i interface{})
	Success(interface{})
	Fail(error)
}

Context defined TODO

type Error

type Error interface {
	Error() string
	Code() uint32
	Status() string
}

type Handler

type Handler interface {
	Handler() http.Handler
	Handle(string, string, ...HandlerFunc)
}

Handler defined TODO

func MustHandler

func MustHandler() Handler

MustHandler defined TODO

type HandlerFunc

type HandlerFunc interface{}

type HandlersChain

type HandlersChain []HandlerFunc

type RouterGroup

type RouterGroup struct {
	Handlers []HandlerFunc
	// contains filtered or unexported fields
}

routerGroup defined TODO

func (*RouterGroup) Group

func (group *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup

Group defined TODO

func (*RouterGroup) Handle

func (group *RouterGroup) Handle(httpMethod, relativePath string, handlerFuncs ...HandlerFunc)

Handle defined TODO

func (*RouterGroup) Static

func (group *RouterGroup) Static(relativePath, root string)

Static defined TODO

func (*RouterGroup) StaticFS

func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem)

StaticFS defined TODO

func (*RouterGroup) Use

func (group *RouterGroup) Use(middleware ...HandlerFunc)

Use defined TODO

type Web

type Web struct {
	RouterGroup
}

func New

func New() *Web

New defined TODO

func (*Web) Run

func (w *Web) Run(addr ...string) error

func (*Web) ServeHTTP

func (w *Web) ServeHTTP(rwr http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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