pig

package module
v0.0.0-...-d8d3109 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

README

P.I.G Web Service


P.I.G 是一个基础网页服务程序框架, 提供了基础的洋葱模型, 最简化的核心模块, 用户可以按需通过编写插件或者引入第三方插件的方式, 来扩展 P.I.G 的功能模块.

运行图示

img.png

文档

https://pig.gitbook.io/p.i.g-framework

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

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

func New

func New() *Application

func (*Application) Pprof

func (a *Application) Pprof() *Application

func (*Application) PrintMeta

func (a *Application) PrintMeta()

func (*Application) Router

func (a *Application) Router(router IRouter) *Application

func (*Application) Run

func (a *Application) Run(port ...int)

func (*Application) Use

func (a *Application) Use(m ...IMiddleware) *Application

type Context

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

func NewContext

func NewContext() *Context

func (*Context) Container

func (c *Context) Container() *di.Container

func (*Context) Request

func (c *Context) Request() *Request

func (*Context) Response

func (c *Context) Response() *Response

type ICache

type ICache[T any] interface {
	Get(key string) T
	Set(key string, value T, expire int64) bool
	Has(key string) bool
	Remove(key string) bool
}

type IHttpErrorHandler

type IHttpErrorHandler interface {
	Handle(any, *Context)
}

type IMiddleware

type IMiddleware interface {
	Handle(*Context, func(*Context))
}

type IRouter

type IRouter interface {
	Route(path string, method constant.RequestMethod) (func(*Context), *param.RequestParamPairs[*param.RequestParamItems[string]], []IMiddleware)
}

type Kernel

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

func NewKernel

func NewKernel(r IRouter) *Kernel

func (*Kernel) Handle

func (k *Kernel) Handle(w http.ResponseWriter, req *http.Request)

func (*Kernel) Through

func (k *Kernel) Through(middleware []IMiddleware) *Kernel

type Pipeline

type Pipeline[T any] struct {
	// contains filtered or unexported fields
}

func NewPipeline

func NewPipeline[T any]() *Pipeline[T]

func (*Pipeline[T]) Send

func (h *Pipeline[T]) Send(i T) *Pipeline[T]

func (*Pipeline[T]) Then

func (h *Pipeline[T]) Then(p func(T))

func (*Pipeline[T]) Through

func (h *Pipeline[T]) Through(unit func(T, func(T))) *Pipeline[T]

type Request

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

func NewRequest

func NewRequest(
	req *http.Request,
	routerParams *param.RequestParamPairs[*param.RequestParamItems[string]],
) *Request

func (*Request) Bind

func (c *Request) Bind(t any)

func (*Request) FileVar

func (c *Request) FileVar() *param.Helper[*param.RequestParamItems[*param.File]]

func (*Request) IsAjax

func (c *Request) IsAjax() bool

func (*Request) IsDelete

func (c *Request) IsDelete() bool

func (*Request) IsGet

func (c *Request) IsGet() bool

func (*Request) IsOption

func (c *Request) IsOption() bool

func (*Request) IsPost

func (c *Request) IsPost() bool

func (*Request) IsPut

func (c *Request) IsPut() bool

func (*Request) JsonBind

func (c *Request) JsonBind(t any)

func (*Request) ParamVar

func (c *Request) ParamVar() *param.Helper[*param.RequestParamItems[string]]

func (*Request) PostVar

func (c *Request) PostVar() *param.Helper[*param.RequestParamItems[string]]

func (*Request) Raw

func (c *Request) Raw() *http.Request

type Response

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

func NewResponse

func NewResponse(w http.ResponseWriter, request *http.Request) *Response

func (*Response) Code

func (c *Response) Code(code int)

func (*Response) Download

func (c *Response) Download(file *param.File, basename string) error

func (*Response) GetCode

func (c *Response) GetCode() int

func (*Response) Header

func (c *Response) Header(key, value string) *Response

func (*Response) Html

func (c *Response) Html(s string, code ...int)

func (*Response) Json

func (c *Response) Json(o any, code ...int)

func (*Response) Raw

func (c *Response) Raw() http.ResponseWriter

func (*Response) Redirect

func (c *Response) Redirect(uri string, code ...int)

func (*Response) Text

func (c *Response) Text(s string, code ...int)

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) ANY

func (r *Router) ANY(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) CONNECT

func (r *Router) CONNECT(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) DELETE

func (r *Router) DELETE(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) GET

func (r *Router) GET(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) Group

func (r *Router) Group(path string, fn func(r *Router), middleware ...IMiddleware)

func (*Router) HEAD

func (r *Router) HEAD(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) Miss

func (r *Router) Miss(f func(*Context)) *Router

func (*Router) OPTION

func (r *Router) OPTION(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) PATCH

func (r *Router) PATCH(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) POST

func (r *Router) POST(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) PUT

func (r *Router) PUT(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

func (*Router) RequestPathId

func (r *Router) RequestPathId(path string, method constant.RequestMethod) string

func (*Router) Route

func (r *Router) Route(
	path string,
	requestMethod constant.RequestMethod,
) (func(*Context), *param.RequestParamPairs[*param.RequestParamItems[string]], []IMiddleware)

func (*Router) TRACE

func (r *Router) TRACE(path string, f func(*Context), middleware ...IMiddleware) *RouterConfig

type RouterConfig

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

func (*RouterConfig) Name

func (a *RouterConfig) Name(name string) *RouterConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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