awshttp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package awshttp holds the HTTP-level plumbing shared by every doze-aws service: the API error type that stores return for API-visible failures, request-id generation, and the date formats AWS wire protocols use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ISO8601

func ISO8601(t time.Time) string

ISO8601 renders t the way AWS XML/JSON APIs expect timestamps (UTC, second precision, trailing Z).

func RequestID

func RequestID() string

RequestID returns a fresh request id in UUID shape. AWS request ids are opaque; UUID shape keeps SDK log lines familiar.

Types

type APIError

type APIError struct {
	Code    string // AWS error code, e.g. "ValidationError"
	Status  int    // HTTP status to respond with
	Message string
	// SenderFault distinguishes 4xx Sender errors from Receiver faults in the
	// Query/XML error envelope.
	SenderFault bool
	// Item optionally carries a wire-format item inside the error body —
	// DynamoDB's ReturnValuesOnConditionCheckFailure.
	Item json.RawMessage
	// Extra merges additional members into the JSON error body (e.g.
	// DynamoDB's CancellationReasons).
	Extra map[string]json.RawMessage
}

APIError is a failure that maps onto an AWS API error: an error code the SDK matches on, an HTTP status, and a human message. Service stores return *APIError for anything a client should see; any other error type is treated as an internal fault (HTTP 500).

func AsAPIError

func AsAPIError(err error) *APIError

AsAPIError coerces err into an *APIError, wrapping unknown error types as an opaque InternalFailure so internal details never leak onto the wire.

func AsAPIErrorOrNil

func AsAPIErrorOrNil(err error) *APIError

AsAPIErrorOrNil is AsAPIError that passes nil through — for the common `return nil, awshttp.AsAPIErrorOrNil(err)` handler tail.

func Errf

func Errf(status int, code, format string, args ...any) *APIError

Errf builds a Sender-fault APIError with a formatted message.

func (*APIError) Error

func (e *APIError) Error() string

Jump to

Keyboard shortcuts

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