Documentation
¶
Overview ¶
Package bodysize carries the request body size limit through a context.Context, from the body-limit middleware (arkoren.dev/core/http/middleware/bodylimit) to the request body helpers (arkoren.dev/core/http/request). It is internal so that only the middleware can set the limit; handlers cannot widen it by writing to the context. The value is a byte count; request helpers interpret absence using their own defaults. This context metadata does not itself wrap or limit an io.Reader.
ctx := bodysize.NewContext(ctx, 1<<20) limit, present := bodysize.FromContext(ctx) fmt.Println(limit, present)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext returns the limit stored in ctx and whether there is one. Absence returns zero and false, distinct from an explicitly stored zero.
Example: limit, present := bodysize.FromContext(bodysize.NewContext(ctx, 1024)); fmt.Println(limit, present)
func NewContext ¶
NewContext returns a copy of ctx that carries n as the body size limit. It retains no reader and performs no validation; the middleware owns policy and actual enforcement. A nil parent follows context.WithValue's panic rule.
Example: ctx := bodysize.NewContext(ctx, 1<<20)
Types ¶
This section is empty.