Help us shape the future of Go! Take the 2026 Go Developer Survey

protocol

package
v2.1.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	HeaderTaskName       = "X-Cloudtasks-Taskname"
	HeaderQueueName      = "X-Cloudtasks-Queuename"
	HeaderTaskRetryCount = "X-Cloudtasks-Taskretrycount"
	HeaderTaskExecCount  = "X-Cloudtasks-Taskexecutioncount"
	HeaderTaskETA        = "X-Cloudtasks-Tasketa"
)

Cloud Tasks HTTP target headers (canonical MIME form used by net/http.Header.Get).

View Source
const (
	ProtocolAuto        = "auto"
	ProtocolRaw         = "raw"
	ProtocolCloudEvents = "cloudevents"
	ProtocolCloudTasks  = "cloudtasks"
	ProtocolGCPPubSub   = "gcppubsub"
)

Protocol preference from subscriber URL query protocol=.

Variables

This section is empty.

Functions

func ApplyClaimTrust added in v2.0.13

func ApplyClaimTrust(md map[string]string, level ClaimTrustLevel) map[string]string

ApplyClaimTrust filters metadata according to trust level.

func IsClaimKey

func IsClaimKey(key string) bool

IsClaimKey reports whether key is claim-shaped authentication metadata.

func SanitizeInbound

func SanitizeInbound(md map[string]string, trustClaims bool) map[string]string

SanitizeInbound applies trust policy to inbound metadata before processDelivery. When trustClaims is false, claim-shaped keys are dropped (TrustNone). When true, all keys are kept (TrustAll). Prefer ApplyClaimTrust for finer control.

Types

type ClaimTrustLevel added in v2.0.13

type ClaimTrustLevel int

ClaimTrustLevel controls which claim-shaped metadata keys are accepted when reconstructing auth claims on consumers.

const (
	// TrustNone drops all claim-shaped keys (push default via SanitizeInbound false).
	TrustNone ClaimTrustLevel = iota
	// TrustTenancyOnly keeps tenant/partition/identity keys but strips roles/service_name
	// so metadata cannot force tenancy.Claims.Skip via roles=internal.
	TrustTenancyOnly
	// TrustAll accepts full ClaimsFromMap input (legacy pull default).
	TrustAll
)

type CloudEvents

type CloudEvents struct{}

CloudEvents decodes CloudEvents 1.0 binary and structured content modes.

func (CloudEvents) Decode

func (c CloudEvents) Decode(r *http.Request) (*Inbound, error)

func (CloudEvents) Match

func (CloudEvents) Match(r *http.Request) bool

func (CloudEvents) Name

func (CloudEvents) Name() string

type CloudTasks

type CloudTasks struct{}

CloudTasks matches Cloud Tasks push requests and maps headers into metadata.

func (CloudTasks) Decode

func (CloudTasks) Decode(r *http.Request) (*Inbound, error)

func (CloudTasks) Match

func (CloudTasks) Match(r *http.Request) bool

func (CloudTasks) Name

func (CloudTasks) Name() string

type Codec

type Codec interface {
	Name() string
	Match(r *http.Request) bool
	Decode(r *http.Request) (*Inbound, error)
}

Codec decodes an HTTP push request into body + metadata.

func DefaultCodecs

func DefaultCodecs() []Codec

DefaultCodecs returns the ordered codec list for protocol=auto.

func SelectCodec

func SelectCodec(protocol string, r *http.Request, codecs []Codec) Codec

SelectCodec picks a codec for the request based on protocol preference.

type GCPPubSub added in v2.0.10

type GCPPubSub struct{}

GCPPubSub decodes Google Cloud Pub/Sub push envelopes:

{
  "message": {
    "data": "<base64>",
    "attributes": { ... },
    "messageId": "...",
    "publishTime": "..."
  },
  "subscription": "projects/.../subscriptions/..."
}

See https://cloud.google.com/pubsub/docs/push#receive_push

func (GCPPubSub) Decode added in v2.0.10

func (GCPPubSub) Decode(r *http.Request) (*Inbound, error)

func (GCPPubSub) Match added in v2.0.10

func (GCPPubSub) Match(r *http.Request) bool

func (GCPPubSub) Name added in v2.0.10

func (GCPPubSub) Name() string

type Inbound

type Inbound struct {
	Body     []byte
	Metadata map[string]string
}

Inbound is a decoded push message ready for processDelivery.

type Raw

type Raw struct{}

Raw decodes a plain HTTP body with a minimal safe header allowlist.

func (Raw) Decode

func (Raw) Decode(r *http.Request) (*Inbound, error)

func (Raw) Match

func (Raw) Match(_ *http.Request) bool

func (Raw) Name

func (Raw) Name() string

Jump to

Keyboard shortcuts

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