httpctx

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasHTTPScheme added in v1.11.0

func HasHTTPScheme(ctx fiber.Ctx) bool

HasHTTPScheme reports whether ctx's request-target is an http or https URI, or has no scheme at all, like an origin-form one ("/path"). S3 rejects an absolute-form target of any other scheme.

func NewCtx added in v1.10.0

func NewCtx(app *fiber.App) fiber.CustomCtx

NewCtx returns a new Ctx of app.

func RequestHost added in v1.11.0

func RequestHost(ctx fiber.Ctx) string

RequestHost returns the host ctx's request is addressed to, exactly as the client sent it: the authority of an absolute-form request-target ("GET http://host/path HTTP/1.1"), which takes precedence over the Host header (RFC 9112, section 3.2.2), or else the Host header. S3 resolves the host the same way, and both routes and signs the request with it.

SigV4 signs this host, so anything deriving the bucket from the host must read it from here too, never from fasthttp's URI().Host(): that one may name another host than the signed one, as it lowercases the host, drops a userinfo prefix, and even takes a host out of an origin-form target like "//host/path#://".

Types

type ContextKey

type ContextKey string

ContextKey names a request-local value stored in fiber.Ctx locals.

const (
	ContextKeyRegion           ContextKey = "region"
	ContextKeyStartTime        ContextKey = "start-time"
	ContextKeyIsRoot           ContextKey = "is-root"
	ContextKeyRootAccessKey    ContextKey = "root-access-key"
	ContextKeyAccount          ContextKey = "account"
	ContextKeyAuthenticated    ContextKey = "authenticated"
	ContextKeyPublicBucket     ContextKey = "public-bucket"
	ContextKeyParsedAcl        ContextKey = "parsed-acl"
	ContextKeySkipResBodyLog   ContextKey = "skip-res-body-log"
	ContextKeyBodyReader       ContextKey = "body-reader"
	ContextKeyBodyStream       ContextKey = "body-stream"
	ContextKeySkip             ContextKey = "__skip"
	ContextKeyStack            ContextKey = "stack"
	ContextKeyBucketOwner      ContextKey = "bucket-owner"
	ContextKeyObjectPostResult ContextKey = "object-post-result"
	ContextKeyRequestID        ContextKey = "request-id"
	ContextKeyHostID           ContextKey = "host-id"
	ContextKeyWebsiteConfig    ContextKey = "website-config"
	ContextKeyCallerIdentity   ContextKey = "iam-caller-identity"
	ContextKeyOriginalURIPath  ContextKey = "original-uri-path"
	ContextKeyClientIP         ContextKey = "client-ip"
)

func (ContextKey) Delete

func (ck ContextKey) Delete(ctx fiber.Ctx)

func (ContextKey) Get

func (ck ContextKey) Get(ctx fiber.Ctx) any

func (ContextKey) IsSet

func (ck ContextKey) IsSet(ctx fiber.Ctx) bool

func (ContextKey) Set

func (ck ContextKey) Set(ctx fiber.Ctx, val any)

type Ctx added in v1.10.0

type Ctx struct {
	*fiber.DefaultCtx
	// contains filtered or unexported fields
}

Ctx is the request context of the gateway servers, created by fiber.NewWithCustomCtx(NewCtx). Fiber normalizes every path it routes as RFC 3986 Section 6.2.2 describes: it decodes the escapes of unreserved characters and removes the "." and ".." segments, and DefaultCtx.Path returns that normalized path, an override included. An S3 path names a bucket and an object key, and S3 takes the key as it is: "a/../b", "x/." and "a%41" are keys of their own. Ctx keeps a path set by Path as it is and has fiber route routePath of it instead.

func (*Ctx) Path added in v1.10.0

func (c *Ctx) Path(override ...string) string

Path returns the path set by the last override, or fiber's normalized path before one. An override is set as the request URI path, like fiber sets it, and fiber routes routePath of it.

func (*Ctx) Reset added in v1.10.0

func (c *Ctx) Reset(fctx *fasthttp.RequestCtx)

Reset prepares c for the request of fctx.

Jump to

Keyboard shortcuts

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