response

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFoundHandler

func NotFoundHandler(w http.ResponseWriter, r *http.Request)

NotFoundHandler If none of the http routes match respond with MethodNotAllowed

func SetHeadGetRespHeaders

func SetHeadGetRespHeaders(w http.ResponseWriter, reqParams url.Values)

SetHeadGetRespHeaders - set any requested parameters as response headers.

func SetObjectHeaders

func SetObjectHeaders(w http.ResponseWriter, r *http.Request, objInfo store.ObjectInfo)

SetObjectHeaders Write object header

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, r *http.Request, errorCode apierrors.ErrorCode)

WriteErrorResponse write ErrorResponse

func WriteErrorResponseHeadersOnly

func WriteErrorResponseHeadersOnly(w http.ResponseWriter, r *http.Request, err apierrors.ErrorCode)

func WriteErrorResponseJSON

func WriteErrorResponseJSON(w http.ResponseWriter, r *http.Request, err apierrors.APIError)

WriteErrorResponseJSON - writes error response in JSON format; useful for admin APIs.

func WriteSTSErrorResponse

func WriteSTSErrorResponse(ctx context.Context, w http.ResponseWriter, isErrCodeSTS bool, errCode apierrors.STSErrorCode, errCtxt error)

WriteSTSErrorResponse writes error headers

func WriteSuccessNoContent

func WriteSuccessNoContent(w http.ResponseWriter)

WriteSuccessNoContent writes success headers with http status 204

func WriteSuccessResponseHeadersOnly

func WriteSuccessResponseHeadersOnly(w http.ResponseWriter, r *http.Request)

WriteSuccessResponseHeadersOnly write SuccessResponseHeadersOnly

func WriteSuccessResponseJSON

func WriteSuccessResponseJSON(w http.ResponseWriter, r *http.Request, response interface{})

WriteSuccessResponseJSON writes success headers and response if any, with content-type set to `application/json`.

func WriteSuccessResponseJSONOnlyData added in v0.4.0

func WriteSuccessResponseJSONOnlyData(w http.ResponseWriter, r *http.Request, response []byte)

WriteSuccessResponseJSONOnlyData writes success headers and response only data if any, with content-type set to `application/json`.

func WriteSuccessResponseXML

func WriteSuccessResponseXML(w http.ResponseWriter, r *http.Request, response interface{})

WriteSuccessResponseXML Write Success Response XML

func WriteXMLResponse

func WriteXMLResponse(w http.ResponseWriter, r *http.Request, statusCode int, response interface{})

WriteXMLResponse Write XMLResponse

Types

type APIErrorResponse

type APIErrorResponse struct {
	XMLName        xml.Name `xml:"Error" json:"Error"`
	HTTPStatusCode int      `xml:"HTTPStatusCode" json:"HTTPStatusCode"`
	Code           string   `xml:"Code" json:"Code"`
	Message        string   `xml:"Message" json:"Message"`
	Resource       string
	RequestID      string `xml:"RequestId" json:"RequestId"`
	HostID         string `xml:"HostId" json:"HostId"`
}

APIErrorResponse - error response format

type APISuccessResponse added in v0.4.0

type APISuccessResponse struct {
	Response       interface{}
	HTTPStatusCode int `xml:"HTTPStatusCode" json:"HTTPStatusCode"`
	Resource       string
	RequestID      string `xml:"RequestId" json:"RequestId"`
	HostID         string `xml:"HostId" json:"HostId"`
}

APISuccessResponse response format

type AccessControlPolicy

type AccessControlPolicy struct {
	Owner             canonicalUser     `xml:"Owner"`
	AccessControlList accessControlList `xml:"AccessControlList"`
}

AccessControlPolicy <AccessControlPolicy>

 <Owner>
   <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID>
   <DisplayName>CustomersName@amazon.com</DisplayName>
 </Owner>
 <AccessControlList>
   <Grant>
     <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xsi:type="CanonicalUser">
       <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID>
       <DisplayName>CustomersName@amazon.com</DisplayName>
     </Grantee>
     <Permission>FULL_CONTROL</Permission>
   </Grant>
 </AccessControlList>

</AccessControlPolicy>

type AssumeRoleResponse

type AssumeRoleResponse struct {
	XMLName xml.Name `xml:"https://sts.amazonaws.com/doc/2011-06-15/ AssumeRoleResponse" json:"-"`

	Result           AssumeRoleResult `xml:"AssumeRoleResult"`
	ResponseMetadata struct {
		RequestID string `xml:"RequestId,omitempty"`
	} `xml:"ResponseMetadata,omitempty"`
}

AssumeRoleResponse contains the result of successful AssumeRole request.

type AssumeRoleResult

type AssumeRoleResult struct {
	// The identifiers for the temporary security credentials that the operation
	// returns.
	AssumedRoleUser AssumedRoleUser `xml:",omitempty"`

	// The temporary security credentials, which include an access key ID, a secret
	// access key, and a security (or session) token.
	//
	// Note: The size of the security token that STS APIs return is not fixed. We
	// strongly recommend that you make no assumptions about the maximum size. As
	// of this writing, the typical size is less than 4096 bytes, but that can vary.
	// Also, future updates to AWS might require larger sizes.
	Credentials auth.Credentials `xml:",omitempty"`

	// A percentage value that indicates the size of the policy in packed form.
	// The service rejects any policy with a packed size greater than 100 percent,
	// which means the policy exceeded the allowed space.
	PackedPolicySize int `xml:",omitempty"`
}

AssumeRoleResult - Contains the response to a successful AssumeRole request, including temporary credentials that can be used to make API requests.

type AssumedRoleUser

type AssumedRoleUser struct {
	// The ARN of the temporary security credentials that are returned from the
	// AssumeRole action. For more information about ARNs and how to use them in
	// policies, see IAM Identifiers (http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html)
	// in Using IAM.
	//
	// Arn is a required field
	Arn string

	// A unique identifier that contains the role ID and the role session name of
	// the role that is being assumed. The role ID is generated by AWS when the
	// role is created.
	//
	// AssumedRoleId is a required field
	AssumedRoleID string `xml:"AssumeRoleId"`
}

AssumedRoleUser - The identifiers for the temporary security credentials that the operation returns. Please also see https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/AssumedRoleUser

type CommonPrefix

type CommonPrefix struct {
	Prefix string
}

CommonPrefix container for prefix response in ListObjectsResponse

type CompleteMultipartUploadResponse

type CompleteMultipartUploadResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CompleteMultipartUploadResult" json:"-"`

	Location string
	Bucket   string
	Key      string
	ETag     string

	ChecksumCRC32  string
	ChecksumCRC32C string
	ChecksumSHA1   string
	ChecksumSHA256 string
}

CompleteMultipartUploadResponse container for completed multipart upload response

func GenerateCompleteMultpartUploadResponse

func GenerateCompleteMultpartUploadResponse(bucket, key, location string, oi store.ObjectInfo) CompleteMultipartUploadResponse

generates CompleteMultipartUploadResponse for given bucket, key, location and ETag.

type CopyObjectResponse

type CopyObjectResponse struct {
	CopyObjectResult CopyObjectResult `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult"`
}

type CopyObjectResult

type CopyObjectResult struct {
	LastModified string `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LastModified"`
	ETag         string `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ETag"`
}

type DeleteError

type DeleteError struct {
	Code      string
	Message   string
	Key       string
	VersionID string `xml:"VersionId"`
}

DeleteError structure.

type DeleteObjectsResponse

type DeleteObjectsResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ DeleteResult" json:"-"`

	// Collection of all deleted objects
	DeletedObjects []datatypes.DeletedObject `xml:"Deleted,omitempty"`

	// Collection of errors deleting certain objects.
	Errors []DeleteError `xml:"Error,omitempty"`
}

DeleteObjectsResponse container for multiple object deletes.

func GenerateMultiDeleteResponse

func GenerateMultiDeleteResponse(quiet bool, deletedObjects []datatypes.DeletedObject, errs []DeleteError) DeleteObjectsResponse

generate multi objects delete response.

type Grant

type Grant struct {
	Grantee    Grantee    `xml:"Grantee"`
	Permission Permission `xml:"Permission"`
}

Grant grant

type Grantee

type Grantee struct {
	XMLNS       string `xml:"xmlns:xsi,attr"`
	XMLXSI      string `xml:"xsi:type,attr"`
	Type        string `xml:"Type"`
	ID          string `xml:"ID,omitempty"`
	DisplayName string `xml:"DisplayName,omitempty"`
	URI         string `xml:"URI,omitempty"`
}

Grantee grant

type InitiateMultipartUploadResponse

type InitiateMultipartUploadResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ InitiateMultipartUploadResult" json:"-"`

	Bucket   string
	Key      string
	UploadID string `xml:"UploadId"`
}

InitiateMultipartUploadResponse container for InitiateMultiPartUpload response, provides uploadID to start MultiPart upload

func GenerateInitiateMultipartUploadResponse

func GenerateInitiateMultipartUploadResponse(bucket, key, uploadID string) InitiateMultipartUploadResponse

generates InitiateMultipartUploadResponse for given bucket, key and uploadID.

type Initiator

type Initiator s3.Owner

Initiator inherit from Owner struct, fields are same

type ListAllMyBucketsResult

type ListAllMyBucketsResult struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult"`
	Owner   *s3.Owner
	Buckets []*s3.Bucket `xml:"Buckets>Bucket"`
}

ListAllMyBucketsResult List All Buckets Result

type ListMultipartUploadsResponse

type ListMultipartUploadsResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListMultipartUploadsResult" json:"-"`

	Bucket             string
	KeyMarker          string
	UploadIDMarker     string `xml:"UploadIdMarker"`
	NextKeyMarker      string
	NextUploadIDMarker string `xml:"NextUploadIdMarker"`
	Delimiter          string
	Prefix             string
	EncodingType       string `xml:"EncodingType,omitempty"`
	MaxUploads         int
	IsTruncated        bool

	// List of pending uploads.
	Uploads []Upload `xml:"Upload"`

	// Delimed common prefixes.
	CommonPrefixes []CommonPrefix
}

ListMultipartUploadsResponse - format for list multipart uploads response.

func GenerateListMultipartUploadsResponse

func GenerateListMultipartUploadsResponse(bucket string, multipartsInfo store.ListMultipartsInfo, encodingType string) ListMultipartUploadsResponse

generates ListMultipartUploadsResponse for given bucket and ListMultipartsInfo.

type ListObjectsResponse

type ListObjectsResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`

	Name   string
	Prefix string
	Marker string

	// When response is truncated (the IsTruncated element value in the response
	// is true), you can use the key name in this field as marker in the subsequent
	// request to get next set of objects. Server lists objects in alphabetical
	// order Note: This element is returned only if you have delimiter request parameter
	// specified. If response does not include the NextMaker and it is truncated,
	// you can use the value of the last Key in the response as the marker in the
	// subsequent request to get the next set of object keys.
	NextMarker string `xml:"NextMarker,omitempty"`

	MaxKeys   int
	Delimiter string
	// A flag that indicates whether or not ListObjects returned all of the results
	// that satisfied the search criteria.
	IsTruncated bool

	Contents       []Object
	CommonPrefixes []CommonPrefix

	// Encoding type used to encode object keys in the response.
	EncodingType string `xml:"EncodingType,omitempty"`
}

ListObjectsResponse - format for list objects response.

func GenerateListObjectsV1Response

func GenerateListObjectsV1Response(bucket, prefix, marker, delimiter, encodingType string, maxKeys int, listObjectsInfo store.ListObjectsInfo) ListObjectsResponse

generates an ListObjectsV1 response for the said bucket with other enumerated options.

type ListObjectsV2Response

type ListObjectsV2Response struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`

	Name       string
	Prefix     string
	StartAfter string `xml:"StartAfter,omitempty"`
	// When response is truncated (the IsTruncated element value in the response
	// is true), you can use the key name in this field as marker in the subsequent
	// request to get next set of objects. Server lists objects in alphabetical
	// order Note: This element is returned only if you have delimiter request parameter
	// specified. If response does not include the NextMaker and it is truncated,
	// you can use the value of the last Key in the response as the marker in the
	// subsequent request to get the next set of object keys.
	ContinuationToken     string `xml:"ContinuationToken,omitempty"`
	NextContinuationToken string `xml:"NextContinuationToken,omitempty"`

	KeyCount  int
	MaxKeys   int
	Delimiter string
	// A flag that indicates whether or not ListObjects returned all of the results
	// that satisfied the search criteria.
	IsTruncated bool

	Contents       []Object
	CommonPrefixes []CommonPrefix

	// Encoding type used to encode object keys in the response.
	EncodingType string `xml:"EncodingType,omitempty"`
}

ListObjectsV2Response - format for list objects response.

func GenerateListObjectsV2Response

func GenerateListObjectsV2Response(bucket, prefix, token, nextToken, startAfter, delimiter, encodingType string, isTruncated bool, maxKeys int, objects []store.ObjectInfo, prefixes []string) ListObjectsV2Response

GenerateListObjectsV2Response Generates an ListObjectsV2 response for the said bucket with other enumerated options.

type ListPartsResponse

type ListPartsResponse struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListPartsResult" json:"-"`

	Bucket   string
	Key      string
	UploadID string `xml:"UploadId"`

	Initiator Initiator
	Owner     s3.Owner

	// The class of storage used to store the object.
	StorageClass string

	PartNumberMarker     int
	NextPartNumberMarker int
	MaxParts             int
	IsTruncated          bool

	ChecksumAlgorithm string
	// List of parts.
	Parts []Part `xml:"Part"`
}

ListPartsResponse - format for list parts response.

func GenerateListPartsResponse

func GenerateListPartsResponse(partsInfo store.ListPartsInfo, encodingType string) ListPartsResponse

generates ListPartsResponse from ListPartsInfo.

type LocationResponse

type LocationResponse struct {
	XMLName  xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LocationConstraint" json:"-"`
	Location string   `xml:",chardata"`
}

LocationResponse - format for location response.

type Object

type Object struct {
	Key          string
	LastModified string // time string of format "2006-01-02T15:04:05.000Z"
	ETag         string
	Size         int64

	// Owner of the object.
	Owner s3.Owner

	// The class of storage used to store the object.
	StorageClass string

	// UserMetadata user-defined metadata
	UserMetadata StringMap `xml:"UserMetadata,omitempty"`
}

Object container for object metadata

type Part

type Part struct {
	PartNumber   int
	LastModified string
	ETag         string
	Size         int64

	// Checksum values
	ChecksumCRC32  string
	ChecksumCRC32C string
	ChecksumSHA1   string
	ChecksumSHA256 string
}

Part container for part metadata.

type Permission

type Permission string

Permission May be one of READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL

type STSErrorResponse

type STSErrorResponse struct {
	XMLName   xml.Name `xml:"https://sts.amazonaws.com/doc/2011-06-15/ Error" json:"-"`
	Code      string   `xml:"Code" json:"Code"`
	Message   string   `xml:"Message" json:"Message"`
	RequestID string   `xml:"RequestId" json:"RequestID"`
	Resource  string   `xml:"Resource" json:"Resource"`
}

STSErrorResponse - error response format

type StringMap

type StringMap map[string]string

StringMap is a map[string]string

func (StringMap) MarshalXML

func (s StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML - StringMap marshals into XML.

type Upload

type Upload struct {
	Key          string
	UploadID     string `xml:"UploadId"`
	Initiator    Initiator
	Owner        s3.Owner
	StorageClass string
	Initiated    string
}

Upload container for in progress multipart upload

Jump to

Keyboard shortcuts

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