http

package
v1.3.2-rc3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnvQueryRouter = kit.NewRouter(&EnvQuery{})
	EnvSetRouter   = kit.NewRouter(&EnvSet{})
)
View Source
var LivenessRouter = kit.NewRouter(&Liveness{})
View Source
var (
	RTypeLivenessChecker = reflect.TypeOf((*LivenessChecker)(nil)).Elem()
)

Functions

func NewLogRoundTripper

func NewLogRoundTripper(logger *logrus.Entry) func(http.RoundTripper) http.RoundTripper

func NewRequest

func NewRequest(method string, path string) *request

func OmitAuthorization

func OmitAuthorization(u *url.URL) string

func RegisterCheckerBy

func RegisterCheckerBy(vs ...interface{})

func RegisterEnvRouters added in v1.1.0

func RegisterEnvRouters(r *kit.Router)

func ResetRegistered

func ResetRegistered()

func TraceLogHandler

func TraceLogHandler(name string) func(handler http.Handler) http.Handler

func TraceLogHandlerWithLogger

func TraceLogHandlerWithLogger(logger *logrus.Entry, name string) func(handler http.Handler) http.Handler

func WithContextCompose

func WithContextCompose(contexts ...contextx.WithContext) contextx.WithContext

func WithMiddlewares

func WithMiddlewares(ms ...httptransport.HttpMiddleware)

WithMiddlewares for custom

Types

type ClientEndpoint

type ClientEndpoint struct {
	Endpoint types.Endpoint `env:""`
	Timeout  time.Duration

	client.Client `env:"-"`
}

func (*ClientEndpoint) Do

func (c *ClientEndpoint) Do(ctx context.Context, req interface{}, metas ...kit.Metadata) kit.Result

func (*ClientEndpoint) Init

func (c *ClientEndpoint) Init()

func (*ClientEndpoint) LivenessCheck

func (c *ClientEndpoint) LivenessCheck() map[string]string

func (*ClientEndpoint) SetDefault

func (c *ClientEndpoint) SetDefault()

type EnvQuery added in v1.1.0

type EnvQuery struct {
	httpx.MethodGet
	K string `in:"query" name:"k,omitempty"`
}

func (*EnvQuery) Output added in v1.1.0

func (r *EnvQuery) Output(ctx context.Context) (interface{}, error)

func (*EnvQuery) Path added in v1.1.0

func (r *EnvQuery) Path() string

type EnvSet added in v1.1.0

type EnvSet struct {
	httpx.MethodPost
	K string `in:"query"           name:"key"`
	V string `in:"query,omitempty" name:"key"`
}

func (*EnvSet) Output added in v1.1.0

func (r *EnvSet) Output(ctx context.Context) (interface{}, error)

func (*EnvSet) Path added in v1.1.0

func (r *EnvSet) Path() string

type Liveness

type Liveness struct{ httpx.MethodGet }

func (Liveness) Output

func (Liveness) Output(ctx context.Context) (interface{}, error)

func (Liveness) Path

func (Liveness) Path() string

type LivenessChecker

type LivenessChecker interface {
	LivenessCheck() map[string]string
}

type LivenessCheckers

type LivenessCheckers map[string]LivenessChecker

func (LivenessCheckers) Statuses

func (cs LivenessCheckers) Statuses() map[string]string

type LogRoundTripper

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

func (*LogRoundTripper) RoundTrip

func (rt *LogRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type LoggerResponseWriter

type LoggerResponseWriter struct {
	http.ResponseWriter
	http.Hijacker
	http.Flusher
	// contains filtered or unexported fields
}

func NewLoggerResponseWriter

func NewLoggerResponseWriter(rw http.ResponseWriter) *LoggerResponseWriter

func (*LoggerResponseWriter) Header

func (rw *LoggerResponseWriter) Header() http.Header

func (*LoggerResponseWriter) Write

func (rw *LoggerResponseWriter) Write(data []byte) (int, error)

func (*LoggerResponseWriter) WriteHeader

func (rw *LoggerResponseWriter) WriteHeader(sc int)

type Middleware

type Middleware = func(http.Handler) http.Handler

func NewContextInjectorMw

func NewContextInjectorMw(ctx contextx.WithContext) Middleware

type Server

type Server struct {
	Port        int    `env:",opt,expose"`
	Spec        string `env:",opt,copy"`
	HealthCheck string `env:",opt,healthCheck"`
	Debug       *bool  `env:""`
	// contains filtered or unexported fields
}

func (*Server) LivenessCheck

func (s *Server) LivenessCheck() map[string]string

func (*Server) Serve

func (s *Server) Serve(router *kit.Router) error

func (*Server) SetDefault

func (s *Server) SetDefault()

func (*Server) Shutdown added in v1.2.2

func (s *Server) Shutdown()

func (Server) WithContextInjector

func (s Server) WithContextInjector(injector contextx.WithContext) *Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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