mirror

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

README

mirror

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Request        *http.Request
	ResponseWriter http.ResponseWriter
	PathParams     map[string]string

	MatchedRoute   string
	RespData       []byte
	RespStatusCode int

	UserValues map[string]any
	// contains filtered or unexported fields
}

func (*Context) BindJSON

func (c *Context) BindJSON(val any) error

func (*Context) BindJSONOpt

func (c *Context) BindJSONOpt(val any, useNumber bool, disableUnknown bool) error

func (*Context) FormValue

func (c *Context) FormValue(key string) StringValue

func (*Context) PathValue

func (c *Context) PathValue(key string) StringValue

func (*Context) QueryValue

func (c *Context) QueryValue(key string) StringValue

func (*Context) Render added in v0.1.1

func (c *Context) Render(templateName string, data any) error

func (*Context) RespJSON

func (c *Context) RespJSON(status int, val any) error

func (*Context) RespJSONOK

func (c *Context) RespJSONOK(val any) error

func (*Context) SetCookie added in v0.1.1

func (c *Context) SetCookie(ck *http.Cookie)

type FileDownloader added in v0.1.1

type FileDownloader struct {
	Dir string
}

func (*FileDownloader) Handle added in v0.1.1

func (f *FileDownloader) Handle() HandleFunc

Handle 文件下载

type FileUploader added in v0.1.1

type FileUploader struct {
	// FileField 对应于文件在表单中的字段名字
	FileField string
	// FileField 对应于文件在表单中的字段名字
	DstPathFunc func(*multipart.FileHeader) string
}

func (*FileUploader) Handle added in v0.1.1

func (f *FileUploader) Handle() HandleFunc

Handle 文件上传

type GoTemplateEngine added in v0.1.1

type GoTemplateEngine struct {
	T *template.Template
}

func (*GoTemplateEngine) Render added in v0.1.1

func (e *GoTemplateEngine) Render(ctx context.Context, templateName string, data any) ([]byte, error)

type HTTPServer

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

func InitHTTPServer added in v0.1.1

func InitHTTPServer(opts ...HTTPServerOption) *HTTPServer

func (*HTTPServer) Connect

func (h *HTTPServer) Connect(path string, handleFunc HandleFunc)

func (*HTTPServer) Delete

func (h *HTTPServer) Delete(path string, handleFunc HandleFunc)

func (*HTTPServer) Get

func (h *HTTPServer) Get(path string, handleFunc HandleFunc)

func (*HTTPServer) Head

func (h *HTTPServer) Head(path string, handleFunc HandleFunc)

func (*HTTPServer) Options

func (h *HTTPServer) Options(path string, handleFunc HandleFunc)

func (*HTTPServer) Patch

func (h *HTTPServer) Patch(path string, handleFunc HandleFunc)

func (*HTTPServer) Post

func (h *HTTPServer) Post(path string, handleFunc HandleFunc)

func (*HTTPServer) Put

func (h *HTTPServer) Put(path string, handleFunc HandleFunc)

func (*HTTPServer) ServeHTTP

func (h *HTTPServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP HTTPServer 处理请求的入口

func (*HTTPServer) Start

func (h *HTTPServer) Start(addr string) error

Start 启动服务器,编程接口

func (*HTTPServer) Trace

func (h *HTTPServer) Trace(path string, handleFunc HandleFunc)

func (*HTTPServer) Use

func (s *HTTPServer) Use(mils ...Middleware)

func (*HTTPServer) UseRoute added in v0.1.3

func (s *HTTPServer) UseRoute(method string, path string, mils ...Middleware)

type HTTPServerOption

type HTTPServerOption func(server *HTTPServer)

func ServerWithMiddleware

func ServerWithMiddleware(mils ...Middleware) HTTPServerOption

func ServerWithTemplateEngine added in v0.1.1

func ServerWithTemplateEngine(templateEngine TemplateEngine) HTTPServerOption

type HandleFunc

type HandleFunc func(ctx *Context)

type Middleware

type Middleware func(next HandleFunc) HandleFunc

type Server

type Server interface {
	http.Handler
	// Start 启动服务器
	// addr 是监听地址
	Start(addr string) error
	// contains filtered or unexported methods
}

type StaticResourceHandler added in v0.1.1

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

func InitStaticResourceHandler added in v0.1.1

func InitStaticResourceHandler(dir string, opts ...StaticResourceHandlerOption) (*StaticResourceHandler, error)

func (*StaticResourceHandler) Handle added in v0.1.1

func (s *StaticResourceHandler) Handle(ctx *Context)

type StaticResourceHandlerOption added in v0.1.1

type StaticResourceHandlerOption func(handler *StaticResourceHandler)

func StaticWithCache added in v0.1.1

func StaticWithCache(c *lru.Cache) StaticResourceHandlerOption

func StaticWithExtension added in v0.1.1

func StaticWithExtension(extMap map[string]string) StaticResourceHandlerOption

func StaticWithMaxFileSize added in v0.1.1

func StaticWithMaxFileSize(maxSize int) StaticResourceHandlerOption

type StringValue

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

func (*StringValue) AsFloat64

func (s *StringValue) AsFloat64() (float64, error)

func (*StringValue) AsInt64

func (s *StringValue) AsInt64() (int64, error)

func (*StringValue) AsUint64

func (s *StringValue) AsUint64() (uint64, error)

type TemplateEngine added in v0.1.1

type TemplateEngine interface {
	// Render 渲染页面
	Render(ctx context.Context, templateName string, data any) ([]byte, error)
}

Directories

Path Synopsis
internal
middlewares

Jump to

Keyboard shortcuts

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