gee

package
v0.0.0-...-d9d496d Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ParamFilePath = "filepath"

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(logger GeeLogger)

func MakeRouterKey

func MakeRouterKey(method string, pattern string) string

func PanicInvalidPattern

func PanicInvalidPattern(pattern string)

Types

type Context

type Context struct {
	// origin objects
	Writer http.ResponseWriter
	Req    *http.Request
	// request info
	Path   string
	Method string
	Params map[string]string
	// response info
	StatusCode int
	// contains filtered or unexported fields
}

func (*Context) Data

func (c *Context) Data(code int, data []byte)

func (*Context) Fail

func (c *Context) Fail(code int, err error)

func (*Context) HTML

func (c *Context) HTML(code int, name string, data any)

func (*Context) Json

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

func (*Context) Next

func (c *Context) Next()

index 记录当前执行到第几个中间件 当在中间件中调用Next方法时,控制权交给了下一个中间件

func (*Context) Param

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

func (*Context) PostForm

func (c *Context) PostForm(key string) string

func (*Context) Query

func (c *Context) Query(key string) string

func (*Context) SetHeader

func (c *Context) SetHeader(k, v string)

func (*Context) Status

func (c *Context) Status(code int)

func (*Context) String

func (c *Context) String(code int, format string, values ...any)

response

type Engine

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

func Default

func Default() *Engine

func New

func New() *Engine

func (*Engine) GET

func (e *Engine) GET(pattern string, handler HandlerFunc)

GET defines the method to add GET request

func (*Engine) LoadHTMLGlob

func (e *Engine) LoadHTMLGlob(pattern string)

func (*Engine) POST

func (e *Engine) POST(pattern string, handler HandlerFunc)

POST defines the method to add POST request

func (*Engine) Run

func (e *Engine) Run(addr string) error

Run defines the method to start a http server

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Engine) SetHtmlFuncMap

func (e *Engine) SetHtmlFuncMap(funcMap template.FuncMap)

type GeeLogger

type GeeLogger interface {
	Info(a ...any)
	Error(a ...any)
}

type H

type H map[string]any

type HandlerFunc

type HandlerFunc func(ctx *Context)

func Logger

func Logger() HandlerFunc

func Recovery

func Recovery() HandlerFunc

type RouterGroup

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

func (*RouterGroup) GET

func (g *RouterGroup) GET(pattern string, handler HandlerFunc)

GET defines the method to add GET request

func (*RouterGroup) Group

func (g *RouterGroup) Group(prefix string) *RouterGroup

func (*RouterGroup) POST

func (g *RouterGroup) POST(pattern string, handler HandlerFunc)

POST defines the method to add POST request

func (*RouterGroup) Static

func (g *RouterGroup) Static(pattern string, root string)

serve static files pattern 为请求该文件夹req路径 root 为磁盘上的某个文件夹

func (*RouterGroup) Use

func (g *RouterGroup) Use(middlewares ...HandlerFunc)

Use is defined to add middleware to the group

Jump to

Keyboard shortcuts

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