server

package
v0.0.0-...-692e367 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerKindHTTPServer = "http"
	ServerKindGRPCServer = "grpc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultHttpServerMiddleware

type DefaultHttpServerMiddleware struct{}

func (DefaultHttpServerMiddleware) Order

type GRPCInterceptor

type GRPCInterceptor interface {
	Kind() KindInterceptor
	Order() int
	Interceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)
}

type GRPCServer

type GRPCServer interface {
	Start(ctx context.Context) error
	Stop() error

	SetDescriptor(descriptor grpc.ServiceDesc)

	SetService(constructor interface{})
	SetConstructor(fn interface{})

	GetInterceptors() []interface{}
	SetInterceptor(interceptor any)

	GetService() interface{}
	GetConstructor() interface{}
	GetInterceptorsConstructor() interface{}

	RegisterService(service interface{})
	Info() ServerInfo
}

type GRPCServerOptions

type GRPCServerOptions struct {
	Host string
	Port int

	TLSConfig *tls.Config
}

type HTTPServer

type HTTPServer interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error

	UseMiddleware(...KindMiddleware)
	UseMarshaler(contentType string, marshaler marshaler.Marshaler) error

	GetMiddlewares() []any
	SetMiddleware(middleware any)

	SetService(service interface{})
	GetService() interface{}

	AddHandler(method, path string, h http.HandlerFunc, opts ...HTTPServerOption)

	GetConstructor() interface{}

	Subscribe(event string, h websockets.EventHandler)
	Info() ServerInfo

	ServerWS(w http.ResponseWriter, r *http.Request)
	SetCorsHandlerFunc(hf http.HandlerFunc)
	SetErrorHandlerFunc(hf func(http.ResponseWriter, error))
}

type HTTPServerHandler

type HTTPServerHandler struct {
	Method  string
	Path    string
	Handler http.HandlerFunc
	Options []HTTPServerOption
}

type HTTPServerOption

type HTTPServerOption interface {
	Kind() HttpOptionKind
}

type HTTPServerOptions

type HTTPServerOptions struct {
	Host string
	Port int

	TLSConfig *tls.Config
}

type HttpOptionKind

type HttpOptionKind string

type HttpServerMiddleware

type HttpServerMiddleware interface {
	Apply(h http.HandlerFunc) http.HandlerFunc
	Kind() KindMiddleware
	Order() int
}

type KindInterceptor

type KindInterceptor string

type KindMiddleware

type KindMiddleware string

type ServerInfo

type ServerInfo struct {
	Kind ServerKind
	Host string
	Port int

	TLSConfig *tls.Config
}

type ServerKind

type ServerKind string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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