Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeResponse(response interface{}) ([]byte, error)
- func EncodeToResponse(w http.ResponseWriter, response interface{}) error
- func EncodeToResponseNoHeader(w http.ResponseWriter, response interface{}) error
- func GetAccessBoxAttrs(ctx context.Context) ([]object.Attribute, error)
- func GetBoxData(ctx context.Context) (*accessbox.Box, error)
- func GetClientTime(ctx context.Context) (time.Time, error)
- func GetReqLog(ctx context.Context) *zap.Logger
- func GetRequestID(v interface{}) string
- func SetBox(ctx context.Context, box *Box) context.Context
- func SetReqInfo(ctx context.Context, req *ReqInfo) context.Context
- func SetReqLogger(ctx context.Context, log *zap.Logger) context.Context
- func StartHTTPServerSpan(r *http.Request, operationName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func WriteErrorResponse(w http.ResponseWriter, reqInfo *ReqInfo, err error) (int, error)
- func WriteResponse(w http.ResponseWriter, statusCode int, response []byte, mType mimeType) error
- func WriteResponseBody(w http.ResponseWriter, response []byte) error
- func WriteSuccessResponseHeadersOnly(w http.ResponseWriter) error
- type AuthHeader
- type Box
- type BucketResolveFunc
- type Center
- type ContainerIDResolveFunc
- type ErrorResponse
- type FrostFSIDInformer
- type FrostFSIDValidator
- type Func
- func AddBucketName(l *zap.Logger) Func
- func AddObjectName(l *zap.Logger) Func
- func Auth(center Center, log *zap.Logger) Func
- func FrostfsIDValidation(frostfsID FrostFSIDValidator, log *zap.Logger) Func
- func LogSuccessResponse(l *zap.Logger) Func
- func Metrics(log *zap.Logger, resolveBucket ContainerIDResolveFunc, ...) Func
- func PolicyCheck(cfg PolicyConfig) Func
- func Request(log *zap.Logger, settings RequestSettings) Func
- func Tracing() Func
- func WrapHandler(handler http.HandlerFunc) Func
- type KeyVal
- type MetricsSettings
- type ObjectRequest
- type PolicyConfig
- type PolicySettings
- type ReqInfo
- type ReqType
- type RequestSettings
- type ResourceTagging
- type XMLDecoder
Constants ¶
const ( ListBucketsOperation = "ListBuckets" OptionsBucketOperation = "OptionsBucket" HeadBucketOperation = "HeadBucket" ListMultipartUploadsOperation = "ListMultipartUploads" GetBucketLocationOperation = "GetBucketLocation" GetBucketPolicyStatusOperation = "GetBucketPolicyStatus" GetBucketPolicyOperation = "GetBucketPolicy" GetBucketLifecycleOperation = "GetBucketLifecycle" GetBucketEncryptionOperation = "GetBucketEncryption" GetBucketCorsOperation = "GetBucketCors" GetBucketACLOperation = "GetBucketACL" GetBucketWebsiteOperation = "GetBucketWebsite" GetBucketAccelerateOperation = "GetBucketAccelerate" GetBucketRequestPaymentOperation = "GetBucketRequestPayment" GetBucketLoggingOperation = "GetBucketLogging" GetBucketReplicationOperation = "GetBucketReplication" GetBucketTaggingOperation = "GetBucketTagging" GetBucketObjectLockConfigOperation = "GetBucketObjectLockConfig" GetBucketVersioningOperation = "GetBucketVersioning" GetBucketNotificationOperation = "GetBucketNotification" ListenBucketNotificationOperation = "ListenBucketNotification" ListBucketObjectVersionsOperation = "ListBucketObjectVersions" ListObjectsV2MOperation = "ListObjectsV2M" ListObjectsV2Operation = "ListObjectsV2" ListObjectsV1Operation = "ListObjectsV1" PutBucketCorsOperation = "PutBucketCors" PutBucketACLOperation = "PutBucketACL" PutBucketLifecycleOperation = "PutBucketLifecycle" PutBucketEncryptionOperation = "PutBucketEncryption" PutBucketPolicyOperation = "PutBucketPolicy" PutBucketObjectLockConfigOperation = "PutBucketObjectLockConfig" PutBucketTaggingOperation = "PutBucketTagging" PutBucketVersioningOperation = "PutBucketVersioning" PutBucketNotificationOperation = "PutBucketNotification" CreateBucketOperation = "CreateBucket" DeleteMultipleObjectsOperation = "DeleteMultipleObjects" PostObjectOperation = "PostObject" DeleteBucketCorsOperation = "DeleteBucketCors" DeleteBucketWebsiteOperation = "DeleteBucketWebsite" DeleteBucketTaggingOperation = "DeleteBucketTagging" DeleteBucketPolicyOperation = "DeleteBucketPolicy" DeleteBucketLifecycleOperation = "DeleteBucketLifecycle" DeleteBucketEncryptionOperation = "DeleteBucketEncryption" DeleteBucketOperation = "DeleteBucket" OptionsObjectOperation = "OptionsObject" HeadObjectOperation = "HeadObject" ListPartsOperation = "ListParts" GetObjectACLOperation = "GetObjectACL" GetObjectTaggingOperation = "GetObjectTagging" GetObjectRetentionOperation = "GetObjectRetention" GetObjectLegalHoldOperation = "GetObjectLegalHold" GetObjectAttributesOperation = "GetObjectAttributes" GetObjectOperation = "GetObject" UploadPartCopyOperation = "UploadPartCopy" UploadPartOperation = "UploadPart" PutObjectACLOperation = "PutObjectACL" PutObjectTaggingOperation = "PutObjectTagging" CopyObjectOperation = "CopyObject" PutObjectRetentionOperation = "PutObjectRetention" PutObjectLegalHoldOperation = "PutObjectLegalHold" PutObjectOperation = "PutObject" CompleteMultipartUploadOperation = "CompleteMultipartUpload" CreateMultipartUploadOperation = "CreateMultipartUpload" SelectObjectContentOperation = "SelectObjectContent" AbortMultipartUploadOperation = "AbortMultipartUpload" DeleteObjectTaggingOperation = "DeleteObjectTagging" DeleteObjectOperation = "DeleteObject" )
const ( UploadsQuery = "uploads" LocationQuery = "location" PolicyStatusQuery = "policyStatus" PolicyQuery = "policy" LifecycleQuery = "lifecycle" EncryptionQuery = "encryption" CorsQuery = "cors" ACLQuery = "acl" WebsiteQuery = "website" AccelerateQuery = "accelerate" RequestPaymentQuery = "requestPayment" LoggingQuery = "logging" ReplicationQuery = "replication" TaggingQuery = "tagging" ObjectLockQuery = "object-lock" VersioningQuery = "versioning" NotificationQuery = "notification" EventsQuery = "events" VersionsQuery = "versions" ListTypeQuery = "list-type" MetadataQuery = "metadata" DeleteQuery = "delete" UploadIDQuery = "uploadId" RetentionQuery = "retention" LegalQuery = "legal" AttributesQuery = "attributes" PartNumberQuery = "partNumber" LegalHoldQuery = "legal-hold" )
const ( QueryVersionID = "versionId" QueryPrefix = "prefix" QueryDelimiter = "delimiter" QueryMaxKeys = "max-keys" )
const ( // MimeNone means no response type. MimeNone mimeType = "" // MimeXML means response type is XML. MimeXML mimeType = "application/xml" )
const (
BucketURLPrm = "bucket"
)
const HdrAmzRequestID = "x-amz-request-id"
Variables ¶
var ErrNoAuthorizationHeader = errors.New("no authorization header")
ErrNoAuthorizationHeader is returned for unauthenticated requests.
Functions ¶
func EncodeResponse ¶
EncodeResponse encodes the response headers into XML format.
func EncodeToResponse ¶
func EncodeToResponse(w http.ResponseWriter, response interface{}) error
EncodeToResponse encodes the response into ResponseWriter.
func EncodeToResponseNoHeader ¶
func EncodeToResponseNoHeader(w http.ResponseWriter, response interface{}) error
EncodeToResponseNoHeader encodes the response into ResponseWriter without header status.
func GetAccessBoxAttrs ¶ added in v0.30.0
GetAccessBoxAttrs extracts []object.Attribute from context.
func GetBoxData ¶
GetBoxData extracts accessbox.Box from context.
func GetClientTime ¶
GetClientTime extracts time.Time from context.
func GetRequestID ¶
func GetRequestID(v interface{}) string
GetRequestID returns the request ID from the response writer or the context.
func SetReqInfo ¶
SetReqInfo sets ReqInfo in the context.
func SetReqLogger ¶
SetReqLogger sets child zap.Logger in the context.
func StartHTTPServerSpan ¶
func StartHTTPServerSpan(r *http.Request, operationName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
StartHTTPServerSpan starts root HTTP server span.
func WriteErrorResponse ¶
WriteErrorResponse writes error headers. returns http error code and error in case of failure of response writing.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, statusCode int, response []byte, mType mimeType) error
WriteResponse writes given statusCode and response into w (with mType header if set).
func WriteResponseBody ¶
func WriteResponseBody(w http.ResponseWriter, response []byte) error
WriteResponseBody writes response into w.
func WriteSuccessResponseHeadersOnly ¶
func WriteSuccessResponseHeadersOnly(w http.ResponseWriter) error
WriteSuccessResponseHeadersOnly writes HTTP (200) OK response with no data to the client.
Types ¶
type AuthHeader ¶ added in v0.29.0
func GetAuthHeaders ¶
func GetAuthHeaders(ctx context.Context) (*AuthHeader, error)
GetAuthHeaders extracts auth.AuthHeader from context.
type Box ¶ added in v0.29.0
type Box struct { AccessBox *accessbox.Box ClientTime time.Time AuthHeaders *AuthHeader Attributes []object.Attribute }
Box contains access box and additional info.
type BucketResolveFunc ¶
BucketResolveFunc is a func to resolve bucket info by name.
type Center ¶ added in v0.29.0
type Center interface { // Authenticate validate and authenticate request. // Must return ErrNoAuthorizationHeader if auth header is missed. Authenticate(request *http.Request) (*Box, error) }
Center is a user authentication interface.
type ContainerIDResolveFunc ¶ added in v0.29.0
ContainerIDResolveFunc is a func to resolve container id by name.
type ErrorResponse ¶
type ErrorResponse struct { XMLName xml.Name `xml:"Error" json:"-"` Code string Message string Key string `xml:"Key,omitempty" json:"Key,omitempty"` BucketName string `xml:"BucketName,omitempty" json:"BucketName,omitempty"` Resource string RequestID string `xml:"RequestId" json:"RequestId"` HostID string `xml:"HostId" json:"HostId"` // The region where the bucket is located. This header is returned // only in HEAD bucket and ListObjects response. Region string `xml:"Region,omitempty" json:"Region,omitempty"` // Captures the server string returned in response header. Server string `xml:"-" json:"-"` // Underlying HTTP status code for the returned error. StatusCode int `xml:"-" json:"-"` }
ErrorResponse -- error response format.
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
Error -- Returns S3 error string.
type FrostFSIDInformer ¶ added in v0.29.0
type FrostFSIDValidator ¶ added in v0.29.0
type Func ¶
func AddBucketName ¶
AddBucketName adds bucket name to ReqInfo from context.
func AddObjectName ¶
AddObjectName adds objects name to ReqInfo from context.
func FrostfsIDValidation ¶ added in v0.29.0
func FrostfsIDValidation(frostfsID FrostFSIDValidator, log *zap.Logger) Func
func LogSuccessResponse ¶
func Metrics ¶
func Metrics(log *zap.Logger, resolveBucket ContainerIDResolveFunc, appMetrics *metrics.AppMetrics, settings MetricsSettings) Func
Metrics wraps http handler for api with basic statistics collection.
func PolicyCheck ¶ added in v0.29.0
func PolicyCheck(cfg PolicyConfig) Func
func Tracing ¶
func Tracing() Func
Tracing adds tracing support for requests. Must be placed after prepareRequest middleware.
func WrapHandler ¶
func WrapHandler(handler http.HandlerFunc) Func
type MetricsSettings ¶ added in v0.29.0
type ObjectRequest ¶
ObjectRequest represents object request data.
type PolicyConfig ¶ added in v0.29.0
type PolicyConfig struct { Storage engine.ChainRouter FrostfsID FrostFSIDInformer Settings PolicySettings Domains []string Log *zap.Logger BucketResolver BucketResolveFunc Decoder XMLDecoder Tagging ResourceTagging }
type PolicySettings ¶ added in v0.29.0
type PolicySettings interface {
PolicyDenyByDefault() bool
}
type ReqInfo ¶
type ReqInfo struct { sync.RWMutex RemoteHost string // Client Host/IP Host string // Node Host/IP UserAgent string // User Agent DeploymentID string // random generated s3-deployment-id RequestID string // x-amz-request-id API string // API name -- GetObject PutObject NewMultipartUpload etc. BucketName string // Bucket name ObjectName string // Object name TraceID string // Trace ID URL *url.URL // Request url Namespace string User string // User owner id Tagging *data.Tagging }
ReqInfo stores the request info.
func GetReqInfo ¶
GetReqInfo returns ReqInfo if set. If ReqInfo isn't set returns new empty ReqInfo.
func NewReqInfo ¶
func NewReqInfo(w http.ResponseWriter, r *http.Request, req ObjectRequest, sourceIPHeader string) *ReqInfo
NewReqInfo returns new ReqInfo based on parameters.