http_server

package
v0.0.0-...-608e6a2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(ctx *fasthttp.RequestCtx) string

ClientIP 获取真实的IP 1.1.1.1, 2.2.2.2, 3.3.3.3

Types

type GatewayParser

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

func (*GatewayParser) ParseRequest

func (p *GatewayParser) ParseRequest(ctx *fiber.Ctx) (*message.Request, error)

func (*GatewayParser) ParseResponse

func (p *GatewayParser) ParseResponse(ctx *fiber.Ctx, req *message.Request, msg *message.Response) error

type GatewayResponse

type GatewayResponse struct {
	Code    int64  `json:"code"`
	TraceId string `json:"trace_id"`
	Msg     string `json:"msg,omitempty"`
	Payload []byte `json:"payload"`
}

type Handler

type Handler struct {
	Method  string
	Path    string
	Uses    []fiber.Handler
	Handler fiber.Handler
	Service *service.Service
}

type Option

type Option func(*Server)

func Config

func Config(c *trellis.HTTPServerConfig) Option

func Router

func Router(r router.Router) Option

func ServerName

func ServerName(name string) Option

func Tracing

func Tracing(fs ...bool) Option

type Parser

type Parser interface {
	ParseRequest(ctx *fiber.Ctx) (*message.Request, error)
	ParseResponse(ctx *fiber.Ctx, req *message.Request, msg *message.Response) error
}

func NewGatewayParser

func NewGatewayParser(services map[string]*service.Service) Parser

func NewServerParser

func NewServerParser() Parser

type Server

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

func NewServer

func NewServer(opts ...Option) (*Server, error)

func (*Server) HandleHTTP

func (p *Server) HandleHTTP(ctx *fiber.Ctx) (err error)

func (*Server) RegisterGroupHandlers

func (p *Server) RegisterGroupHandlers(cfgs ...*trellis.HTTPGroup) error

func (*Server) RegisterHandlers

func (p *Server) RegisterHandlers(cfgs ...*trellis.HTTPHandler) error

func (*Server) Start

func (p *Server) Start() error

func (*Server) Stop

func (p *Server) Stop() error

type ServerParser

type ServerParser struct{}

func (*ServerParser) ParseRequest

func (*ServerParser) ParseRequest(ctx *fiber.Ctx) (*message.Request, error)

func (*ServerParser) ParseResponse

func (*ServerParser) ParseResponse(ctx *fiber.Ctx, req *message.Request, msg *message.Response) error

Jump to

Keyboard shortcuts

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