awssig

package
v2.38.8 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package awssig holds the shared AWS SigV4 signing and Bedrock Mantle routing helpers used by both the anthropic-go and openai-go interceptors. It depends only on stdlib and the AWS SDK so it can be imported from either SDK-specific interceptor package without pulling in the other SDK.

Index

Constants

View Source
const PRMUserAgent = "sdk-ua-app-id/APN_1.1%2Fpc_cdfmjwn8i6u8l9fwz8h82e4w3%24"

PRMUserAgent is Coder's AWS Partner Revenue Measurement (PRM) attribution marker for outbound Bedrock requests. It is appended to the User-Agent header so AWS can recognize the traffic as Coder-associated Bedrock usage.

It is Bedrock-specific: only the Bedrock option builders apply it. Other AWS-signed endpoints must not send it without their own attribution agreement.

View Source
const ServiceBedrockMantle = "bedrock-mantle"

ServiceBedrockMantle is the AWS SigV4 service name for Bedrock Mantle.

Variables

This section is empty.

Functions

func AppendPRMUserAgent

func AppendPRMUserAgent(req *http.Request)

AppendPRMUserAgent appends the Coder PRM attribution marker to the request's User-Agent header.

func BaseURLForModel

func BaseURLForModel(rawBase, model string) (string, error)

BaseURLForModel resolves the upstream Mantle base URL for a given model. It parses rawBase, trims any existing vendor path segment, then re-appends the one the model requires: "anthropic." models use /anthropic, "openai." models use /openai/v1, and anything else (third-party) uses /v1 so the SDK's /chat/completions route hits the root /v1/chat/completions endpoint.

func BearerMiddleware

func BearerMiddleware(token string) func(req *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error)

BearerMiddleware authenticates a request with a user-supplied AWS Bedrock API key instead of SigV4. Callers install it in place of SignMiddleware so no deployment AWS credentials are resolved for the request.

func SignMiddleware

func SignMiddleware(creds aws.CredentialsProvider, region, service string) func(req *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error)

SignMiddleware returns an stdlib HTTP middleware that SigV4-signs the request for the named AWS service. It reads and restores the body for hashing, then signs with the given credentials and region. Callers wrap it in their SDK-specific option.WithMiddleware adapter.

The caller is responsible for service-specific headers and user-agent attribution.

Types

type MantleConfig

type MantleConfig struct {
	BaseURL string
	Region  string
	Creds   aws.CredentialsProvider
}

MantleConfig carries only what the OpenAI-shaped interceptors need to reach Bedrock Mantle: the signing region and credentials, and the base URL that BaseURLForModel rewrites per model. It deliberately excludes the InvokeModel fields (Model, SmallFastModel, Protocol) that those interceptors never use; the messages interceptor keeps the full messages.BedrockRuntime for those.

Jump to

Keyboard shortcuts

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