fasthttp

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 13 Imported by: 0

README

FastHTTP

什么是FastHTTP?

FastHTTP是golang下的一个http框架,顾名思义,与原生的http实现相比,它的特点在于快,按照官网的说法,它的客户端和服务端性能比原生有了十倍的提升。

它的高性能主要源自于“复用”,通过服务协程和内存变量的复用,节省了大量资源分配的成本。

参考资料

Documentation

Index

Constants

View Source
const (
	KindFastHttp transport.Kind = "fasthttp"
)

Variables

This section is empty.

Functions

func SetOperation

func SetOperation(ctx context.Context, op string)

SetOperation sets the transport operation.

Types

type FilterFunc

func FilterChain

func FilterChain(filters ...FilterFunc) FilterFunc

type Server

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

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) CONNECT

func (s *Server) CONNECT(path string, handler fasthttp.RequestHandler)

func (*Server) DELETE

func (s *Server) DELETE(path string, handler fasthttp.RequestHandler)

func (*Server) Endpoint

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

func (*Server) GET

func (s *Server) GET(path string, handler fasthttp.RequestHandler)

func (*Server) HEAD

func (s *Server) HEAD(path string, handler fasthttp.RequestHandler)

func (*Server) Handle

func (s *Server) Handle(method, path string, handler fasthttp.RequestHandler)

func (*Server) OPTIONS

func (s *Server) OPTIONS(path string, handler fasthttp.RequestHandler)

func (*Server) PATCH

func (s *Server) PATCH(path string, handler fasthttp.RequestHandler)

func (*Server) POST

func (s *Server) POST(path string, handler fasthttp.RequestHandler)

func (*Server) PUT

func (s *Server) PUT(path string, handler fasthttp.RequestHandler)

func (*Server) Start

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

func (*Server) Stop

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

func (*Server) TRACE

func (s *Server) TRACE(path string, handler fasthttp.RequestHandler)

type ServerOption

type ServerOption func(*Server)

func WithAddress

func WithAddress(addr string) ServerOption

func WithErrorEncoder

func WithErrorEncoder(en kHttp.EncodeErrorFunc) ServerOption

func WithFilter

func WithFilter(filters ...FilterFunc) ServerOption

func WithMiddleware

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

func WithRequestDecoder

func WithRequestDecoder(dec kHttp.DecodeRequestFunc) ServerOption

func WithResponseEncoder

func WithResponseEncoder(en kHttp.EncodeResponseFunc) ServerOption

func WithStrictSlash

func WithStrictSlash(strictSlash bool) ServerOption

func WithTLSConfig

func WithTLSConfig(c *tls.Config) ServerOption

func WithTimeout

func WithTimeout(timeout time.Duration) ServerOption

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

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

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

Jump to

Keyboard shortcuts

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