httpy

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

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 5 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 {
	// origin objects
	Writer http.ResponseWriter
	Req    *http.Request
	// request info
	Path   string
	Method string
	// response info
	StatusCode int
	// get path params
	Params map[string]string
}

func NewContext

func NewContext(w http.ResponseWriter, req *http.Request) *Context

func (*Context) ReqBody

func (c *Context) ReqBody(v any) error

func (*Context) ReqParam

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

func (*Context) ReqQuery

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

func (*Context) ResAddHeader

func (c *Context) ResAddHeader(key string, val string)

func (*Context) ResFlex

func (c *Context) ResFlex(code int, typ string, message string) error

func (*Context) ResJson

func (c *Context) ResJson(code int, obj interface{}) error

func (*Context) ResSetStatuscode

func (c *Context) ResSetStatuscode(code int)

func (*Context) ResString

func (c *Context) ResString(code int, message string) error

type Engine

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

func New

func New() *Engine

func (*Engine) ServeHTTP

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

type H

type H map[string]interface{}

type HandlerFunc

type HandlerFunc func(c *Context) error

type RouterGroup

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

func (*RouterGroup) GET

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

GET defines the method to add GET request

func (*RouterGroup) Group

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

Group is defined to create a new RouterGroup remember all groups share the same Engine instance

func (*RouterGroup) POST

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

POST defines the method to add POST request

Directories

Path Synopsis
poc

Jump to

Keyboard shortcuts

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