http

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestFromServerContext

func RequestFromServerContext(ctx context.Context) (*http.Request, bool)

RequestFromServerContext returns request from context.

func SetOperation

func SetOperation(ctx context.Context, op string)

SetOperation sets the transport operation.

Types

type FilterFunc

type FilterFunc func(http.Handler) http.Handler

FilterFunc is a function which receives a http.Handler and returns another http.Handler.

func FilterChain

func FilterChain(filters ...FilterFunc) FilterFunc

FilterChain returns a FilterFunc that specifies the chained handler for HTTP Router.

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server is an HTTP server wrapper.

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer creates an HTTP server by options.

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

Endpoint return a real address to registry endpoint. examples:

https://127.0.0.1:8000
Legacy: http://127.0.0.1:8000?isSecure=false

func (*Server) Health

func (s *Server) Health() bool

Health 心跳检测

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start start the HTTP server.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stop the HTTP server.

func (*Server) Use

func (s *Server) Use(selector string, m ...middleware.Middleware)

Use uses a service middleware with selector. selector:

  • '/*'
  • '/helloworld.v1.Greeter/*'
  • '/helloworld.v1.Greeter/SayHello'

type ServerOption

type ServerOption func(*Server)

ServerOption is an HTTP server option.

func Address

func Address(addr string) ServerOption

Address with server address.

func Filter

func Filter(filters ...FilterFunc) ServerOption

Filter with HTTP middleware option.

func Listener

func Listener(lis net.Listener) ServerOption

Listener with server lis

func Middleware

func Middleware(m ...middleware.Middleware) ServerOption

Middleware with service middleware option.

func Network

func Network(network string) ServerOption

Network with server network.

func ReadTimeout

func ReadTimeout(timeout time.Duration) ServerOption

ReadTimeout with server timeout.

func TLSConfig

func TLSConfig(c *tls.TLS) ServerOption

TLSConfig with TLS config.

func Timeout

func Timeout(timeout time.Duration) ServerOption

Timeout with server timeout.

type Transport

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

Transport is an HTTP transport.

func (*Transport) Endpoint

func (tr *Transport) Endpoint() string

Endpoint returns the transport endpoint.

func (*Transport) Kind

func (tr *Transport) Kind() transport.Kind

Kind returns the transport kind.

func (*Transport) Operation

func (tr *Transport) Operation() string

Operation returns the transport operation.

func (*Transport) PathTemplate

func (tr *Transport) PathTemplate() string

PathTemplate returns the http path template.

func (*Transport) ReplyHeader added in v1.10.0

func (tr *Transport) ReplyHeader() transport.Header

ReplyHeader returns the reply header.

func (*Transport) Request

func (tr *Transport) Request() *http.Request

Request returns the HTTP request.

func (*Transport) RequestHeader added in v1.10.0

func (tr *Transport) RequestHeader() transport.Header

RequestHeader returns the request header.

type Transporter

type Transporter interface {
	transport.Transporter
	Request() *http.Request
	PathTemplate() string
}

Transporter is http Transporter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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