http_server

package
v0.0.0-...-ba4ac1c Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultGzipConfig = GzipConfig{
	Skipper: emiddleware.DefaultSkipper,
	Level:   -1,
}

DefaultGzipConfig is the default Gzip middleware config.

Functions

func ArraySortingStream

func ArraySortingStream(ctx context.Context, data <-chan *Response, expected int) io.Reader

func Gzip

func Gzip() echo.MiddlewareFunc

Gzip returns a middleware which compresses HTTP response using gzip compression scheme.

func GzipWithConfig

func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc

GzipWithConfig return Gzip middleware with config. See: `Gzip()`.

func HandleWebsocket

func HandleWebsocket(
	ctx context.Context,
	conn *websocket.Conn,
	chain string,
	authPayload auth.AuthPayload,
	appCtx *server_ctx.ApplicationServerContext,
)

func NewHttpServer

func NewHttpServer(ctx context.Context, appCtx *server_ctx.ApplicationServerContext) *echo.Echo

func NewSortingReader

func NewSortingReader(ctx context.Context, data <-chan *Response, expected int) io.Reader

func StartEcho

func StartEcho(e *echo.Echo, addr string, tlsCfg *config.TlsConfig) error

Types

type DropLastReader

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

func (*DropLastReader) Read

func (d *DropLastReader) Read(buf []byte) (int, error)

type FastJSONSerializer

type FastJSONSerializer struct{}

func (FastJSONSerializer) Deserialize

func (FastJSONSerializer) Deserialize(c echo.Context, i interface{}) error

func (FastJSONSerializer) Serialize

func (FastJSONSerializer) Serialize(c echo.Context, i interface{}, indent string) error

type GzipConfig

type GzipConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper emiddleware.Skipper

	// Gzip compression level.
	// Optional. Default value -1.
	Level int `yaml:"level"`
}

GzipConfig defines the config for Gzip middleware.

type HandleResponse

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

func NewHandleResponse

func NewHandleResponse(responseWrappers chan *protocol.ResponseHolderWrapper, corsOrigins []string) *HandleResponse

type JsonRpcHandler

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

func NewJsonRpcHandler

func NewJsonRpcHandler(preReq *Request, requestBody io.Reader, isWsCtx bool) (*JsonRpcHandler, error)

func (*JsonRpcHandler) GetRequestType

func (j *JsonRpcHandler) GetRequestType() protocol.RequestType

func (*JsonRpcHandler) IsSingle

func (j *JsonRpcHandler) IsSingle() bool

func (*JsonRpcHandler) RequestCount

func (j *JsonRpcHandler) RequestCount() int

func (*JsonRpcHandler) RequestDecode

func (j *JsonRpcHandler) RequestDecode(ctx context.Context) (*Request, error)

func (*JsonRpcHandler) ResponseEncode

func (j *JsonRpcHandler) ResponseEncode(response protocol.ResponseHolder) *Response

type Request

type Request struct {
	Chain            string
	UpstreamRequests []protocol.RequestHolder
}

type RequestHandler

type RequestHandler interface {
	RequestDecode(context.Context) (*Request, error)
	ResponseEncode(response protocol.ResponseHolder) *Response
	IsSingle() bool
	RequestCount() int
	GetRequestType() protocol.RequestType
}

type Response

type Response struct {
	ResponseReader io.Reader
	Order          int
}

type RestHandler

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

func NewRestHandler

func NewRestHandler(preReq *Request, req *http.Request, restPath string) (*RestHandler, error)

NewRestHandler builds a REST handler from an incoming HTTP request. restPath is the path under /queries/{chain}/ (already URL-decoded by echo, with the query string stripped). The query string and headers are carried on req so the parser can promote them into RequestParams. For GETs and other no-body verbs the request body is allowed to be empty; only non-empty bodies are validated as JSON so callers like algod's REST API don't get rejected at parse time.

func (*RestHandler) GetRequestType

func (r *RestHandler) GetRequestType() protocol.RequestType

func (*RestHandler) IsSingle

func (r *RestHandler) IsSingle() bool

func (*RestHandler) RequestCount

func (r *RestHandler) RequestCount() int

func (*RestHandler) RequestDecode

func (r *RestHandler) RequestDecode(_ context.Context) (*Request, error)

func (*RestHandler) ResponseEncode

func (r *RestHandler) ResponseEncode(response protocol.ResponseHolder) *Response

type SingleByteReader

type SingleByteReader []byte

func (SingleByteReader) Read

func (r SingleByteReader) Read(buf []byte) (int, error)

type SortingReader

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

func (*SortingReader) Read

func (a *SortingReader) Read(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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