s3err

package
v0.0.0-...-5c6c1e7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeXML mimeType = "application/xml"
)

Variables

View Source
var (
	Logger *fluent.Fluent
)

Functions

func EncodeXMLResponse

func EncodeXMLResponse(response interface{}) []byte

Encodes the response headers into XML format.

func InitAuditLog

func InitAuditLog(config string)

func NotFoundHandler

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

If none of the http routes match respond with MethodNotAllowed

func PostAccessLog

func PostAccessLog(log AccessLog)

func PostLog

func PostLog(r *http.Request, HTTPStatusCode int, errorCode ErrorCode)

func WriteEmptyResponse

func WriteEmptyResponse(w http.ResponseWriter, r *http.Request, statusCode int)

func WriteErrorResponse

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

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *http.Request, statusCode int, response []byte, mType mimeType)

func WriteXMLResponse

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

Types

type APIError

type APIError struct {
	Code           string
	Description    string
	HTTPStatusCode int
}

APIError structure

func GetAPIError

func GetAPIError(code ErrorCode) APIError

GetAPIError provides API Error for input API error code.

type AccessLog

type AccessLog struct {
	Bucket           string `msg:"bucket" json:"bucket"`                   // awsexamplebucket1
	Time             int64  `msg:"time" json:"time"`                       // [06/Feb/2019:00:00:38 +0000]
	RemoteIP         string `msg:"remote_ip" json:"remote_ip,omitempty"`   // 192.0.2.3
	Requester        string `msg:"requester" json:"requester,omitempty"`   // IAM user id
	RequestID        string `msg:"request_id" json:"request_id,omitempty"` // 3E57427F33A59F07
	Operation        string `msg:"operation" json:"operation,omitempty"`   // REST.HTTP_method.resource_type REST.PUT.OBJECT
	Key              string `msg:"key" json:"key,omitempty"`               // /photos/2019/08/puppy.jpg
	ErrorCode        string `msg:"error_code" json:"error_code,omitempty"`
	HostId           string `msg:"host_id" json:"host_id,omitempty"`
	HostHeader       string `msg:"host_header" json:"host_header,omitempty"` // s3.us-west-2.amazonaws.com
	UserAgent        string `msg:"user_agent" json:"user_agent,omitempty"`
	HTTPStatus       int    `msg:"status" json:"status,omitempty"`
	SignatureVersion string `msg:"signature_version" json:"signature_version,omitempty"`
}

func GetAccessLog

func GetAccessLog(r *http.Request, HTTPStatusCode int, s3errCode ErrorCode) *AccessLog

type AccessLogExtend

type AccessLogExtend struct {
	AccessLog
	AccessLogHTTP
}

type AccessLogHTTP

type AccessLogHTTP struct {
	RequestURI         string `json:"request_uri,omitempty"` // "GET /awsexamplebucket1/photos/2019/08/puppy.jpg?x-foo=bar HTTP/1.1"
	BytesSent          string `json:"bytes_sent,omitempty"`
	ObjectSize         string `json:"object_size,omitempty"`
	TotalTime          int    `json:"total_time,omitempty"`
	TurnAroundTime     int    `json:"turn_around_time,omitempty"`
	Referer            string `json:"Referer,omitempty"`
	VersionId          string `json:"version_id,omitempty"`
	CipherSuite        string `json:"cipher_suite,omitempty"`
	AuthenticationType string `json:"auth_type,omitempty"`
	TLSVersion         string `json:"TLS_version,omitempty"`
}

func GetAccessHttpLog

func GetAccessHttpLog(r *http.Request, statusCode int, s3errCode ErrorCode) AccessLogHTTP

type ErrorCode

type ErrorCode int

ErrorCode type of error status.

const (
	ErrNone ErrorCode = iota
	ErrAccessDenied
	ErrMethodNotAllowed
	ErrBucketNotEmpty
	ErrBucketAlreadyExists
	ErrBucketAlreadyOwnedByYou
	ErrNoSuchBucket
	ErrNoSuchBucketPolicy
	ErrNoSuchCORSConfiguration
	ErrNoSuchLifecycleConfiguration
	ErrNoSuchKey
	ErrNoSuchUpload
	ErrInvalidBucketName
	ErrInvalidDigest
	ErrInvalidMaxKeys
	ErrInvalidMaxUploads
	ErrInvalidMaxParts
	ErrInvalidMaxDeleteObjects
	ErrInvalidPartNumberMarker
	ErrInvalidPart
	ErrInvalidRange
	ErrInternalError
	ErrInvalidCopyDest
	ErrInvalidCopySource
	ErrInvalidTag
	ErrAuthHeaderEmpty
	ErrSignatureVersionNotSupported
	ErrMalformedPOSTRequest
	ErrPOSTFileRequired
	ErrPostPolicyConditionInvalidFormat
	ErrEntityTooSmall
	ErrEntityTooLarge
	ErrMissingFields
	ErrMissingCredTag
	ErrCredMalformed
	ErrMalformedXML
	ErrMalformedDate
	ErrMalformedPresignedDate
	ErrMalformedCredentialDate
	ErrMissingSignHeadersTag
	ErrMissingSignTag
	ErrUnsignedHeaders
	ErrInvalidQueryParams
	ErrInvalidQuerySignatureAlgo
	ErrExpiredPresignRequest
	ErrMalformedExpires
	ErrNegativeExpires
	ErrMaximumExpires
	ErrSignatureDoesNotMatch
	ErrContentSHA256Mismatch
	ErrInvalidAccessKeyID
	ErrRequestNotReadyYet
	ErrMissingDateHeader
	ErrInvalidRequest
	ErrAuthNotSetup
	ErrNotImplemented
	ErrPreconditionFailed

	ErrExistingObjectIsDirectory
	ErrExistingObjectIsFile

	ErrTooManyRequest
	ErrRequestBytesExceed
)

Error codes, see full list at http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html

type RESTErrorResponse

type RESTErrorResponse struct {
	XMLName    xml.Name `xml:"Error" json:"-"`
	Code       string   `xml:"Code" json:"Code"`
	Message    string   `xml:"Message" json:"Message"`
	Resource   string   `xml:"Resource" json:"Resource"`
	RequestID  string   `xml:"RequestId" json:"RequestId"`
	Key        string   `xml:"Key,omitempty" json:"Key,omitempty"`
	BucketName string   `xml:"BucketName,omitempty" json:"BucketName,omitempty"`

	// Underlying HTTP status code for the returned error
	StatusCode int `xml:"-" json:"-"`
}

RESTErrorResponse - error response format

func (RESTErrorResponse) Error

func (e RESTErrorResponse) Error() string

Error - Returns S3 error string.

Jump to

Keyboard shortcuts

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