rhttp

package
v0.0.0-...-bac8e5f Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIdKey = "*req*"
)

Variables

This section is empty.

Functions

func AddRequestLogExtra

func AddRequestLogExtra(r *http.Request, name string, val interface{})

在request的log中添加extra信息

func FlushErr

func FlushErr(w http.ResponseWriter, r *http.Request, err error)

func GenerateReqId

func GenerateReqId(r *http.Request) string

func JsonBody

func JsonBody(r *http.Request) (st *base.Struct, err error)

func JsonBodyTo

func JsonBodyTo(r *http.Request, v interface{}) error

func ListenAndServe

func ListenAndServe(serveAt string, r *rrouter.Router) error

func Middleware_gzip

func Middleware_gzip(handler http.Handler) http.Handler

func Middleware_httpRequestLog

func Middleware_httpRequestLog(handler http.Handler) http.Handler

func Middleware_panicLog

func Middleware_panicLog(handle http.HandlerFunc) http.HandlerFunc

Types

type ClientConfig

type ClientConfig struct {
	BaseUrl string `yml:"baseUrl"`
}

type RenderConfig

type RenderConfig struct {
	Directory string `yml:"directory"`
	Layout    string `yml:"layout"`
}

type Resp

type Resp struct {
	Status int         `json:"result"`
	Msg    string      `json:"msg"`
	Desc   string      `json:"desc"`
	Data   interface{} `json:"data"`
}

func NewErrResp

func NewErrResp(status int, msg string, desc string) *Resp

func NewResp

func NewResp(data interface{}) *Resp

func (*Resp) Html

func (res *Resp) Html(w http.ResponseWriter, tpl string) error

func (*Resp) Json

func (res *Resp) Json(w http.ResponseWriter) error

type RespErr

type RespErr struct {
	Status int
	Msg    string
	Desc   string
}

func NewRespErr

func NewRespErr(status int, msg, desc string) RespErr

func (RespErr) Error

func (e RespErr) Error() string

func (RespErr) Flush

func (e RespErr) Flush(w http.ResponseWriter, r *http.Request)

type ServerConfig

type ServerConfig struct {
	Render         *RenderConfig `yml:"render"`
	ReadTimeoutMs  int64         `yml:"readtimeoutMs"`
	WriteTimeoutMs int64         `yml:"writetimeoutMs"`
	Middlewares    []string      `yml:"middlewares"`
}

Jump to

Keyboard shortcuts

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