quic

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

nolint:ireturn

Index

Constants

View Source
const (
	DefaultMaxRequestBodySize = 64 * 1024 * 1024
)
View Source
const (
	InternalErrorCode = 500
)

Variables

This section is empty.

Functions

func WithRequest

func WithRequest(ctx context.Context, req *Request) context.Context

Types

type Middleware

type Middleware func(next StreamHandler) StreamHandler

func DecodeRequestMiddleware

func DecodeRequestMiddleware() Middleware

func ErrorHandler

func ErrorHandler(logger log.Logger) Middleware

nolint:nonamedreturns

func MaxRequestBodySize

func MaxRequestBodySize(maxBytes int64) Middleware

func Recovery

func Recovery() Middleware

func RequestId

func RequestId() Middleware

nolint:err113

type Option

type Option func(*Server)

func WithMiddlewares

func WithMiddlewares(mws ...Middleware) Option

func WithQUICConfig

func WithQUICConfig(quicConf *quicLib.Config) Option

func WithTLSConfig

func WithTLSConfig(tlsConf *tls.Config) Option

type QuicError

type QuicError interface {
	ErrorCode() uint64
}

QuicError represents an error that provide error code.

type Request

type Request struct {
	Address string        `json:"-"`
	Timeout time.Duration `json:"-"`
	Body    json.RawMessage
	Headers map[string]string
}

func DecodeRequest

func DecodeRequest(stream Stream) (*Request, error)

func RequestFromContext

func RequestFromContext(ctx context.Context) (*Request, bool)

type Response

type Response struct {
	Body    []byte            `json:"body"`
	Headers map[string]string `json:"headers"`
}

func DecodeResponse

func DecodeResponse(stream Stream) (*Response, error)

func (*Response) Write

func (r *Response) Write(stream Stream) error

type Server

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

func DefaultServer

func DefaultServer(logger log.Logger) *Server

func NewServer

func NewServer(opts ...Option) *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context, addr string) error

func (*Server) Listener

func (s *Server) Listener() *quic.Listener

func (*Server) Shutdown

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

func (*Server) Upgrade

func (s *Server) Upgrade(h StreamHandler)

type Stream

type Stream interface {
	StreamID() int64
	Read(p []byte) (int, error)
	Write(p []byte) (int, error)
	CancelWrite(errorCode uint64)
	CancelRead(errorCode uint64)
	Context() context.Context
	Close() error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	SetDeadline(t time.Time) error
}

type StreamHandler

type StreamHandler interface {
	HandleStream(ctx context.Context, stream Stream) error
}

func ChainMiddleware

func ChainMiddleware(handler StreamHandler, mws ...Middleware) StreamHandler

type StreamHandlerFunc

type StreamHandlerFunc func(ctx context.Context, stream Stream) error

func (StreamHandlerFunc) HandleStream

func (f StreamHandlerFunc) HandleStream(ctx context.Context, s Stream) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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