internal

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_HTTP_PORT   = "80"
	HEADER_XHTTP_METHOD = "X-Http-Method"

	StatusNotFound = 404

	LOGGER_PREFIX = "[host-fasthttp] "
)

Variables

View Source
var (
	GlobalTracerManager *TracerManager = NewTraceManager() // be register from FasthttpHost

	FasthttpHostModuleInstance = FasthttpHostModule{}

	FasthttpHostLogger *log.Logger = log.New(os.Stdout, LOGGER_PREFIX, log.LstdFlags|log.Lmsgprefix)
)
View Source
var (
	RouteResolveModuleInstance = new(StdRouteResolveModule)
)

Functions

This section is empty.

Types

type Defer

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

func (*Defer) Do

func (d *Defer) Do(do func(f Finalizer))

type ErrorHandler

type ErrorHandler func(ctx *RequestCtx, err interface{})

function

type FasthttpHost

type FasthttpHost struct {
	Server         *Server
	Listener       net.Listener
	ListenAddress  string
	EnableCompress bool
	Version        string
	// contains filtered or unexported fields
}

func (*FasthttpHost) Logger

func (h *FasthttpHost) Logger() *log.Logger

func (*FasthttpHost) Start

func (h *FasthttpHost) Start(ctx context.Context)

func (*FasthttpHost) Stop

func (h *FasthttpHost) Stop(ctx context.Context) error

type FasthttpHostModule

type FasthttpHostModule struct{}

func (FasthttpHostModule) ConfigureLogger

func (FasthttpHostModule) ConfigureLogger(logflags int, w io.Writer)

ConfigureLogger implements host.HostService

func (FasthttpHostModule) DescribeHostType

func (FasthttpHostModule) DescribeHostType() reflect.Type

DescribeHostType implements host.HostService

func (FasthttpHostModule) Init

func (FasthttpHostModule) Init(h host.Host, app *host.AppModule)

Init implements host.HostService

func (FasthttpHostModule) InitComplete

func (FasthttpHostModule) InitComplete(h host.Host, app *host.AppModule)

InitComplete implements host.HostService

type FasthttpHostRegistrar

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

func NewFasthttpHostRegistrar

func NewFasthttpHostRegistrar(host *FasthttpHost) *FasthttpHostRegistrar

func (*FasthttpHostRegistrar) AddRoute

func (r *FasthttpHostRegistrar) AddRoute(method string, path string, handler RequestHandler, handlerComponentID string)

func (*FasthttpHostRegistrar) EnableTracer

func (r *FasthttpHostRegistrar) EnableTracer(enabled bool)

func (*FasthttpHostRegistrar) RegisterRequestHandleModule

func (r *FasthttpHostRegistrar) RegisterRequestHandleModule(module RequestHandleModule)

func (*FasthttpHostRegistrar) RegisterRouteResolveModule

func (r *FasthttpHostRegistrar) RegisterRouteResolveModule(module RouteResolveModule)

func (*FasthttpHostRegistrar) SetErrorHandler

func (r *FasthttpHostRegistrar) SetErrorHandler(handler ErrorHandler)

func (*FasthttpHostRegistrar) SetRequestManager

func (r *FasthttpHostRegistrar) SetRequestManager(requestManager interface{})

func (*FasthttpHostRegistrar) SetRewriteHandler

func (r *FasthttpHostRegistrar) SetRewriteHandler(handler RewriteHandler)

func (*FasthttpHostRegistrar) SetUnhandledRequestHandler

func (r *FasthttpHostRegistrar) SetUnhandledRequestHandler(handler RequestHandler)

type Finalizer

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

func (Finalizer) Add

func (f Finalizer) Add(actions ...func(err interface{}))

type OnHostErrorHandler

type OnHostErrorHandler func(err error) (disposed bool)

function

type Recover

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

func (*Recover) Defer

func (s *Recover) Defer(catch func(err interface{})) *Defer

type RequestCtx

type RequestCtx = fasthttp.RequestCtx

import

type RequestHandleModule

type RequestHandleModule interface {
	CanSetSuccessor() bool
	SetSuccessor(successor RequestHandleModule)
	ProcessRequest(ctx *RequestCtx, state RequestState, recover *Recover)
	OnInitComplete()
	OnStart(ctx context.Context) error
	OnStop(ctx context.Context) error
}

interface

type RequestHandleService

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

func NewRequestHandleService

func NewRequestHandleService() *RequestHandleService

func (*RequestHandleService) ProcessRequest

func (s *RequestHandleService) ProcessRequest(ctx *RequestCtx, state RequestState, recover *Recover)

func (*RequestHandleService) Register

func (s *RequestHandleService) Register(module RequestHandleModule)

type RequestHandler

type RequestHandler = fasthttp.RequestHandler

import

type RequestState

type RequestState struct {
	Tracer    *trace.SeverityTracer
	Span      *trace.SeveritySpan
	RoutePath *RoutePath
}

type RequestTracerService

type RequestTracerService struct {
	TracerManager *TracerManager

	Enabled bool
	// contains filtered or unexported fields
}

func (*RequestTracerService) TextMapPropagator

func (s *RequestTracerService) TextMapPropagator() propagation.TextMapPropagator

func (*RequestTracerService) Tracer

type RequestWorker

type RequestWorker struct {
	RequestHandleService *RequestHandleService
	RequestTracerService *RequestTracerService
	RouteResolveService  *RouteResolveService
	Router               Router

	OnHostErrorProc OnHostErrorHandler

	ErrorHandler            ErrorHandler
	UnhandledRequestHandler RequestHandler
	RewriteHandler          RewriteHandler
}

func (*RequestWorker) ProcessRequest

func (w *RequestWorker) ProcessRequest(ctx *RequestCtx)

type RewriteHandler

type RewriteHandler func(ctx *RequestCtx, path *RoutePath) *RoutePath

function

type RouteComponent

type RouteComponent struct {
	RequestHandler     RequestHandler
	HandlerComponentID string
}

type RoutePath

type RoutePath struct {
	Method string
	Path   string
}

func (*RoutePath) String

func (p *RoutePath) String() string

type RouteResolveModule

type RouteResolveModule interface {
	RouteResolver

	CanSetSuccessor() bool
	SetSuccessor(successor RouteResolver)
}

interface

type RouteResolveService

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

func NewRouteResolveService

func NewRouteResolveService() *RouteResolveService

func (*RouteResolveService) Register

func (s *RouteResolveService) Register(successor RouteResolveModule)

func (*RouteResolveService) ResolveHttpMethod

func (s *RouteResolveService) ResolveHttpMethod(ctx *RequestCtx) string

func (*RouteResolveService) ResolveHttpPath

func (s *RouteResolveService) ResolveHttpPath(ctx *RequestCtx) string

type RouteResolver

type RouteResolver interface {
	ResolveHttpMethod(ctx *RequestCtx) string
	ResolveHttpPath(ctx *RequestCtx) string
}

interface

type Router

type Router map[RoutePath]RouteComponent

func (Router) Add

func (r Router) Add(method string, path string, handler RequestHandler, handlerComponentID string)

func (Router) FindHandlerComponentID

func (r Router) FindHandlerComponentID(method string, path string) string

func (Router) Get

func (r Router) Get(method string, path string) RequestHandler

func (Router) Has

func (r Router) Has(path RoutePath) bool

func (Router) Remove

func (r Router) Remove(method string, path string)

type Server

type Server = fasthttp.Server

import

type StdRequestHandleModule

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

func NewStdRequestHandleModule

func NewStdRequestHandleModule(worker *RequestWorker) *StdRequestHandleModule

func (*StdRequestHandleModule) CanSetSuccessor

func (*StdRequestHandleModule) CanSetSuccessor() bool

CanSetSuccessor implements RequestHandleModule

func (*StdRequestHandleModule) OnInitComplete

func (*StdRequestHandleModule) OnInitComplete()

OnInitComplete implements RequestHandleModule

func (*StdRequestHandleModule) OnStart

OnStart implements RequestHandleModule

func (*StdRequestHandleModule) OnStop

OnStop implements RequestHandleModule

func (*StdRequestHandleModule) ProcessRequest

func (m *StdRequestHandleModule) ProcessRequest(ctx *RequestCtx, state RequestState, recover *Recover)

ProcessRequest implements RequestHandleModule

func (*StdRequestHandleModule) SetSuccessor

func (*StdRequestHandleModule) SetSuccessor(successor RequestHandleModule)

SetSuccessor implements RequestHandleModule

type StdRouteResolveModule

type StdRouteResolveModule struct{}

func (*StdRouteResolveModule) CanSetSuccessor

func (r *StdRouteResolveModule) CanSetSuccessor() bool

func (*StdRouteResolveModule) ResolveHttpMethod

func (r *StdRouteResolveModule) ResolveHttpMethod(ctx *RequestCtx) string

func (*StdRouteResolveModule) ResolveHttpPath

func (r *StdRouteResolveModule) ResolveHttpPath(ctx *RequestCtx) string

func (*StdRouteResolveModule) SetSuccessor

func (r *StdRouteResolveModule) SetSuccessor(successor RouteResolver)

type StopError

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

func (*StopError) Error

func (e *StopError) Error() string

func (*StopError) Unwrap

func (e *StopError) Unwrap() error

type TracerManager

type TracerManager struct {
	TracerProvider    *trace.SeverityTracerProvider
	TextMapPropagator propagation.TextMapPropagator
	// contains filtered or unexported fields
}

func NewTraceManager

func NewTraceManager() *TracerManager

func (*TracerManager) GenerateManagedTracer

func (m *TracerManager) GenerateManagedTracer(v interface{}) *trace.SeverityTracer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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