Documentation
¶
Index ¶
- Constants
- func ArraySortingStream(ctx context.Context, data <-chan *Response, expected int) io.Reader
- func Compress() echo.MiddlewareFunc
- func Decompress() echo.MiddlewareFunc
- func HandleWebsocket(ctx context.Context, conn *websocket.Conn, chain string, ...)
- func NewHttpServer(ctx context.Context, appCtx *server_ctx.ApplicationServerContext) *echo.Echo
- func NewSortingReader(ctx context.Context, data <-chan *Response, expected int) io.Reader
- func StartEcho(e *echo.Echo, addr string, tlsCfg *config.TlsConfig) error
- type DropLastReader
- type FastJSONSerializer
- type JsonRpcHandler
- func (j *JsonRpcHandler) GetRequestType() protocol.RequestType
- func (j *JsonRpcHandler) IsSingle() bool
- func (j *JsonRpcHandler) RequestCount() int
- func (j *JsonRpcHandler) RequestDecode(ctx context.Context) (*server_ctx.Request, error)
- func (j *JsonRpcHandler) ResponseEncode(response protocol.ResponseHolder) *Response
- type RequestHandler
- type Response
- type RestHandler
- func (r *RestHandler) GetRequestType() protocol.RequestType
- func (r *RestHandler) IsSingle() bool
- func (r *RestHandler) RequestCount() int
- func (r *RestHandler) RequestDecode(_ context.Context) (*server_ctx.Request, error)
- func (r *RestHandler) ResponseEncode(response protocol.ResponseHolder) *Response
- type SingleByteReader
- type SortingReader
Constants ¶
const MaxDecodedRequestBytes = 32 << 20
MaxDecodedRequestBytes caps how much a single request body may decode to.
A compressed body is a size multiplier whose factor the sender chooses: DEFLATE tops out near 1000:1, zstd and brotli have no comparable ceiling, so without a cap a few hundred kilobytes on the wire can ask nodecore to hold gigabytes - from anyone who can reach the port. The window cap in internal/compression bounds what one frame header can make a decoder allocate; this bounds what the decoded bytes themselves can.
32MiB is far above anything JSON-RPC produces in practice - a batch of ten thousand calls is on the order of a megabyte - so it is a ceiling on abuse rather than a limit real traffic meets.
Variables ¶
This section is empty.
Functions ¶
func ArraySortingStream ¶
func Compress ¶
func Compress() echo.MiddlewareFunc
Compress returns a middleware that compresses the response body with the coding the client asked for - zstd, br or gzip, whichever Negotiate picks. A client that asks for neither is served plain bytes.
func Decompress ¶
func Decompress() echo.MiddlewareFunc
Decompress returns a middleware that decodes a compressed request body, so handlers always read plain bytes whatever the client sent. Codings nodecore does not speak are passed through untouched rather than guessed at, and only a body nodecore actually decodes is capped - an unknown coding is bytes the client had to send in full, which is its own limit.
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 ¶
Types ¶
type DropLastReader ¶
type DropLastReader struct {
// contains filtered or unexported fields
}
type FastJSONSerializer ¶
type FastJSONSerializer struct{}
func (FastJSONSerializer) Deserialize ¶
func (FastJSONSerializer) Deserialize(c echo.Context, i interface{}) error
type JsonRpcHandler ¶
type JsonRpcHandler struct {
// contains filtered or unexported fields
}
func NewJsonRpcHandler ¶
func NewJsonRpcHandler(preReq *server_ctx.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) (*server_ctx.Request, error)
func (*JsonRpcHandler) ResponseEncode ¶
func (j *JsonRpcHandler) ResponseEncode(response protocol.ResponseHolder) *Response
type RequestHandler ¶
type RequestHandler interface {
RequestDecode(context.Context) (*server_ctx.Request, error)
ResponseEncode(response protocol.ResponseHolder) *Response
IsSingle() bool
RequestCount() int
GetRequestType() protocol.RequestType
}
type RestHandler ¶
type RestHandler struct {
// contains filtered or unexported fields
}
func NewRestHandler ¶
func NewRestHandler(preReq *server_ctx.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) (*server_ctx.Request, error)
func (*RestHandler) ResponseEncode ¶
func (r *RestHandler) ResponseEncode(response protocol.ResponseHolder) *Response
type SingleByteReader ¶
type SingleByteReader []byte
type SortingReader ¶
type SortingReader struct {
// contains filtered or unexported fields
}