Documentation
¶
Overview ¶
Package awsjson implements the AWS JSON 1.0/1.1 protocols: POST / with an X-Amz-Target header naming the action ("Prefix.Action"), a JSON body, and JSON responses. DynamoDB and modern SQS speak 1.0; KMS, SSM, Secrets Manager and EventBridge speak 1.1. The two versions differ only in the Content-Type they echo and minor error-shape history — one codec covers both.
Errors travel as HTTP status + {"__type":"Code","message":"..."} plus the x-amzn-ErrorType header, which is what both SDK generations match on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API struct {
// TargetPrefix is the service's X-Amz-Target prefix, e.g. "AmazonSQS",
// "DynamoDB_20120810", "TrentService".
TargetPrefix string
// JSONVersion is "1.0" or "1.1" (sets the response Content-Type).
JSONVersion string
}
API decodes requests and renders responses for one JSON-protocol service.
func (API) Action ¶
Action extracts the action name from the X-Amz-Target header, validating the service prefix.
func (API) ContentType ¶
ContentType returns the protocol's content type, e.g. "application/x-amz-json-1.0".
func (API) Write ¶
func (a API) Write(w http.ResponseWriter, result any)
Write renders a success response. A nil result writes an empty JSON object (the SDKs expect a body even for result-less actions).
func (API) WriteError ¶
func (a API) WriteError(w http.ResponseWriter, e *awshttp.APIError)
WriteError renders the JSON-protocol error shape with e's HTTP status.