httpwrap

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Conf = Config{
		Port: 15001,
		Test: true,
	}

	Flags = []cli.Flag{
		&cli.IntFlag{
			Name:        "HTTP_PORT",
			Value:       5001,
			Usage:       "-HTTP_PORT 7001",
			EnvVars:     []string{"HTTP_PORT"},
			Destination: &Conf.Port,
		},
		&cli.BoolFlag{
			Name:        "HTTP_TEST",
			Value:       true,
			Usage:       "-HTTP_TEST true",
			EnvVars:     []string{"HTTP_TEST"},
			Destination: &Conf.Test,
		},
	}
)

Functions

func CreateHTTPServer

func CreateHTTPServer()

func GetVersion

func GetVersion() int

GetVersion 版本号

func RegisterGetHandle

func RegisterGetHandle(subPath string, handle Handle)

RegisterGetHandle 注册http get handle

func RegisterGetHandleNoUserID

func RegisterGetHandleNoUserID(subPath string, handle Handle)

RegisterGetHandleNoUserID 注册http post handle

func RegisterPostHandle

func RegisterPostHandle(subPath string, handle Handle)

RegisterPostHandle 注册http post handle

func RegisterPostHandleNoUserID

func RegisterPostHandleNoUserID(subPath string, handle Handle)

RegisterPostHandleNoUserID 注册http post handle

Types

type Config

type Config struct {
	Port int  `csv:"noHolidaysTime"`
	Test bool `csv:"holidaysTime"`
}

type Context

type Context struct {
	Rds       redis.Conn
	Db        *xorm.Engine
	MqChannel *mqwrap.MqChannel
	UserID    string
	Query     url.Values
	Params    httprouter.Params
	Body      []byte

	W   http.ResponseWriter
	Ctx context.Context
	// contains filtered or unexported fields
}

func (*Context) GetHTTPRequest

func (ctx *Context) GetHTTPRequest() *http.Request

GetHTTPRequest 获取请求信息

func (*Context) WriteRsp

func (ctx *Context) WriteRsp(m *pb.HTTPResponse)

WriteRsp send protobuf messsage to peer

type Handle

type Handle func(*Context)

Jump to

Keyboard shortcuts

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