server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextPool = sync.Pool{
	New: func() interface{} {
		return &Context{
			Request: Request{
				Body:    make([]byte, 0),
				Headers: http.Header{},
			},
			Response: Response{
				Body:       make([]byte, 0),
				StatusCode: 200,
			},
		}
	},
}

Functions

This section is empty.

Types

type Context

type Context struct {
	Request  Request
	Response Response
}

func FromHttp

func FromHttp(request *http.Request) *Context

type Http

type Http struct {
	Name          string
	Port          string
	RouteRegister func(router *Router)
	// contains filtered or unexported fields
}

func (*Http) Init

func (t *Http) Init(app interfaces.IService) error

func (*Http) ServeHTTP

func (t *Http) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Http) Stop

func (t *Http) Stop() error

func (*Http) String

func (t *Http) String() string

type Mock

type Mock struct {
	Name          string
	RouteRegister func(router *Router)
	// contains filtered or unexported fields
}

func (*Mock) Init

func (t *Mock) Init(app interfaces.IService) error

func (*Mock) Stop

func (t *Mock) Stop() error

func (*Mock) String

func (t *Mock) String() string

type Request

type Request struct {
	Body    []byte
	Headers http.Header
	Ip      net.IP
}

type Response

type Response struct {
	Body       []byte
	StatusCode int
}

type RouteFunc

type RouteFunc func(ctx *Context)

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) Delete

func (t *Router) Delete(path string, handler RouteFunc)

func (*Router) Find

func (t *Router) Find(method string, path string) RouteFunc

func (*Router) Get

func (t *Router) Get(path string, handler RouteFunc)

func (*Router) Post

func (t *Router) Post(path string, handler RouteFunc)

func (*Router) PushRoute

func (t *Router) PushRoute(method string, path string, handler RouteFunc)

func (*Router) Put

func (t *Router) Put(path string, handler RouteFunc)

func (*Router) Rpc

func (t *Router) Rpc(path string, handler RouteFunc)

Jump to

Keyboard shortcuts

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