ddhttp

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Code generated by go generate; DO NOT EDIT. This file was generated by go-doudou at 2021-06-13 16:10:05.662259 +0800 CST m=+0.003993663

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger added in v0.2.4

func Logger(inner http.Handler) http.Handler

func Metrics added in v0.2.4

func Metrics(inner http.Handler) http.Handler

func NewClient added in v0.2.3

func NewClient() *resty.Client

func Rest added in v0.2.4

func Rest(inner http.Handler) http.Handler

Types

type ChiHttpSrv

type ChiHttpSrv struct {
	*chi.Mux
	// contains filtered or unexported fields
}

TODO https://github.com/go-chi/chi

type DefaultHttpSrv

type DefaultHttpSrv struct {
	*mux.Router
	// contains filtered or unexported fields
}

gorilla

func (*DefaultHttpSrv) AddMiddleware

func (srv *DefaultHttpSrv) AddMiddleware(mwf ...func(http.Handler) http.Handler)

func (*DefaultHttpSrv) AddRoute

func (srv *DefaultHttpSrv) AddRoute(route ...Route)

func (*DefaultHttpSrv) Run

func (srv *DefaultHttpSrv) Run()

type HttpLog added in v0.2.4

type HttpLog struct {
	ClientIp          string
	HttpMethod        string
	Uri               string
	Proto             string
	Host              string
	ReqContentLength  int64
	ReqHeader         http.Header
	RequestId         string
	RawReq            string
	RespBody          string
	StatusCode        int
	RespHeader        http.Header
	RespContentLength int
	ElapsedTime       string
	// in ms
	Elapsed int64
}

POST /usersvc/pageusers HTTP/1.1 Host: localhost:6060 Content-Length: 80 Content-Type: application/json User-Agent: go-resty/2.6.0 (https://github.com/go-resty/resty) X-Request-Id: d1e4dc83-18be-493e-be5b-2e0faaca90ec

{"filter":{"dept":99,"name":"Jack"},"page":{"orders":null,"pageNo":2,"size":10}}

func (HttpLog) MarshalJSON added in v0.2.4

func (object HttpLog) MarshalJSON() ([]byte, error)

type IServiceProvider added in v0.2.3

type IServiceProvider interface {
	SelectServer() (string, error)
}

func NewMemberlistServiceProvider added in v0.2.4

func NewMemberlistServiceProvider(name string, registry registry.IRegistry, opts ...MemberlistProviderOption) IServiceProvider

func NewServiceProvider added in v0.2.3

func NewServiceProvider(name string, opts ...ServiceProviderOption) IServiceProvider

type MemberlistProviderOption added in v0.2.4

type MemberlistProviderOption func(IServiceProvider)

type MemberlistServiceProvider added in v0.2.4

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

func (*MemberlistServiceProvider) SelectServer added in v0.2.4

func (m *MemberlistServiceProvider) SelectServer() (string, error)

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

type ServiceProvider added in v0.2.3

type ServiceProvider struct {
	Name string
}

func (*ServiceProvider) SelectServer added in v0.2.3

func (s *ServiceProvider) SelectServer() (string, error)

type ServiceProviderOption added in v0.2.3

type ServiceProviderOption func(IServiceProvider)

type Srv

type Srv interface {
	// Run the service
	Run()
	// Register routes
	AddRoute(route ...Route)
	// Use middleware
	AddMiddleware(mwf ...func(http.Handler) http.Handler)
}

func NewDefaultHttpSrv

func NewDefaultHttpSrv() Srv

Jump to

Keyboard shortcuts

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