bzweb

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

func (*Context) ResponseString

func (c *Context) ResponseString(i int, s string)

type Controller

type Controller func(c *Context) error

func TimeoutHandler

func TimeoutHandler(fun Controller, d time.Duration) Controller

type Group

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

Group struct 实现了IGroup

func (*Group) Delete

func (g *Group) Delete(uri string, handler Controller)

func (*Group) Get

func (g *Group) Get(uri string, handler Controller)

func (*Group) Post

func (g *Group) Post(uri string, handler Controller)

func (*Group) Put

func (g *Group) Put(uri string, handler Controller)

type IContext

type IContext struct {
	// BaseContext 用来为整个链条创建初始化 Context
	// 如果没有设置的话,默认使用 context.Background()
	BaseContext func(net.Listener) context.Context

	// ConnContext 用来为每个连接封装 Context
	// 参数中的 context.Context 是从 BaseContext 继承来的
	ConnContext func(ctx context.Context, c net.Conn) context.Context
}

type IGroup

type IGroup interface {
	Get(string, Controller)
	Post(string, Controller)
	Put(string, Controller)
	Delete(string, Controller)
}

IGroup 代表前缀分组

type Server

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

func New

func New() *Server

func (*Server) Delete

func (c *Server) Delete(url string, handler Controller)

func (*Server) FindRouteByRequest

func (c *Server) FindRouteByRequest(request *http.Request) Controller

FindRouteByRequest 匹配路由,如果没有匹配到,返回nil

func (*Server) Get

func (c *Server) Get(url string, handler Controller)

func (*Server) Group

func (s *Server) Group(prefix string) IGroup

Group 从core中初始化这个Group

func (*Server) Post

func (c *Server) Post(url string, handler Controller)

func (*Server) Put

func (c *Server) Put(url string, handler Controller)

func (*Server) Run

func (s *Server) Run(addr ...string) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type Tree

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

Tree 代表树结构

func (*Tree) AddRouter

func (tree *Tree) AddRouter(uri string, handler Controller) error

增加路由节点

/book/list /book/:id (冲突) /book/:id/name /book/:student/age /:user/name /:user/name/:age(冲突)

func (*Tree) FindHandler

func (tree *Tree) FindHandler(uri string) Controller

FindHandler 匹配uri

Jump to

Keyboard shortcuts

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