api

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 36 Imported by: 0

README

API layer

Part of the code are stolen from https://github.com/minio/minio, and modified accordingly.

Apache license.

Documentation

Index

Constants

View Source
const (
	CombinedLogFormat = "{time_local} {request_uri} {request_id} {operation_name} {host_name} {bucket_name} {object_name} " +
		"{object_size} {requester_id} {project_id} {remote_addr} {http_x_real_ip} {request_length} {server_cost} " +
		"{request_time} {http_status} {error_code} {body_bytes_sent} {http_referer} {http_user_agent}"

	BillingLogFormat = "{is_private_subnet} {storage_class} {target_storage_class} {bucket_logging} {cdn_request}"
)
View Source
const (
	MIN_PART_SIZE = 5 << 20 // 5MB
)

Variables

View Source
var CommonS3ResponseHeaders = []string{"Content-Length", "Content-Type", "Connection", "Date", "ETag", "Server",
	"x-amz-delete-marker", "x-amz-id-2", "x-amz-request-id", "x-amz-version-id"}

Refer: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html

View Source
var ValidSuccessActionStatus = []string{"200", "201", "204"}

Functions

func CheckValidBucketName

func CheckValidBucketName(bucketName string) (err error)

CheckValidBucketName - checks if we have a valid input bucket name.

func ContextLogger

func ContextLogger(r *http.Request) log.Logger

func EncodeResponse

func EncodeResponse(response interface{}) []byte

Encodes the response headers into XML format.

func GenerateCompleteMultpartUploadResponse

func GenerateCompleteMultpartUploadResponse(bucket, key, location, etag string) CompleteMultipartUploadResponse

GenerateCompleteMultipartUploadResponse

func GenerateCopyObjectPartResponse

func GenerateCopyObjectPartResponse(etag string, lastModified time.Time) CopyObjectPartResponse

func GenerateCopyObjectResponse

func GenerateCopyObjectResponse(etag string, lastModified time.Time) CopyObjectResponse

GenerateCopyObjectResponse

func GenerateInitiateMultipartUploadResponse

func GenerateInitiateMultipartUploadResponse(bucket, key, uploadID string) InitiateMultipartUploadResponse

GenerateInitiateMultipartUploadResponse

func GenerateListBucketsResponse

func GenerateListBucketsResponse(buckets []meta.Bucket, credential common.Credential) ListBucketsResponse

Takes an array of Bucket metadata information for serialization input: array of bucket metadata output: populated struct that can be serialized to match xml and json api spec output

func GenerateListObjectsResponse

func GenerateListObjectsResponse(bucketName string, request ListObjectsRequest,
	objectsInfo meta.ListObjectsInfo) (response ListObjectsResponse)

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

func GenerateRenameObjectResponse

func GenerateRenameObjectResponse(lastModified time.Time) RenameObjectResponse

GenerateRenameObjectResponse

func GenerateVersionedListObjectResponse

func GenerateVersionedListObjectResponse(bucketName string, request ListObjectsRequest,
	objectsInfo meta.VersionedListObjectsInfo) (response VersionedListObjectsResponse)

func GetBucketAndObjectInfoFromRequest added in v0.6.1

func GetBucketAndObjectInfoFromRequest(r *http.Request) (bucketName string, objectName string, isBucketDomain bool)

func GetLocation

func GetLocation(r *http.Request) string

getLocation get URL location.

func GetObjectLocation

func GetObjectLocation(bucketName string, key string) string

getObjectLocation gets the relative URL for an object

func GetSourceIP

func GetSourceIP(r *http.Request) string

GetSourceIP retrieves the IP from the X-Forwarded-For, X-Real-IP and RFC7239 Forwarded headers (in that order), falls back to r.RemoteAddr when all else fails.

func InReservedOrigins

func InReservedOrigins(origin string) bool

func IsBucketPolicyAllowed

func IsBucketPolicyAllowed(userId string, bucket *meta.Bucket, r *http.Request, action policy.Action, objectName string) (allow bool, err error)

func NewAccessLogHandler

func NewAccessLogHandler(handler http.Handler, _ *meta.Meta) http.Handler

func RegisterAPIRouter

func RegisterAPIRouter(mux *router.Router, api ObjectAPIHandlers)

registerAPIRouter - registers S3 compatible APIs.

func RegisterHandlers

func RegisterHandlers(router *mux.Router, metadata *meta.Meta, handlerFns ...HandlerFunc) http.Handler

func SetCommonHeaderHandler

func SetCommonHeaderHandler(h http.Handler, _ *meta.Meta) http.Handler

func SetCorsHandler

func SetCorsHandler(h http.Handler, _ *meta.Meta) http.Handler

setCorsHandler handler for CORS (Cross Origin Resource Sharing)

func SetGenerateContextHandler

func SetGenerateContextHandler(h http.Handler, meta *meta.Meta) http.Handler

setAuthHandler to validate authorization header for the incoming request.

func SetIgnoreResourcesHandler

func SetIgnoreResourcesHandler(h http.Handler, _ *meta.Meta) http.Handler

setIgnoreResourcesHandler - Ignore resources handler is wrapper handler used for API request resource validation Since we do not support all the S3 queries, it is necessary for us to throw back a valid error message indicating that requested feature is not implemented.

func SetLogHandler

func SetLogHandler(h http.Handler, _ *meta.Meta) http.Handler

func SetObjectHeaders

func SetObjectHeaders(w http.ResponseWriter, object *meta.Object, contentRange *HttpRange, statusCode int)

Write object header

func SetRequestIdHandler

func SetRequestIdHandler(h http.Handler, _ *meta.Meta) http.Handler

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, r *http.Request, err error)

writeErrorResponse write error headers

func WriteErrorResponseHeaders

func WriteErrorResponseHeaders(w http.ResponseWriter, r *http.Request, err error) (handled bool)

func WriteErrorResponseNoHeader

func WriteErrorResponseNoHeader(w http.ResponseWriter, req *http.Request, err error, resource string)

func WriteErrorResponseWithResource

func WriteErrorResponseWithResource(w http.ResponseWriter, r *http.Request, err error, resource string)

func WriteSuccessNoContent

func WriteSuccessNoContent(w http.ResponseWriter)

writeSuccessNoContent write success headers with http status 204

func WriteSuccessResponse

func WriteSuccessResponse(w http.ResponseWriter, response []byte)

WriteSuccessResponse write success headers and response if any.

Types

type AccessLogHandler

type AccessLogHandler struct {
	// contains filtered or unexported fields
}

func (AccessLogHandler) ServeHTTP

func (a AccessLogHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ApiErrorResponse

type ApiErrorResponse struct {
	XMLName      xml.Name `xml:"Error" json:"-"`
	AwsErrorCode string   `xml:"Code"`
	Message      string
	Key          string
	BucketName   string
	Resource     string
	RequestId    string
	HostId       string
}

APIErrorResponse - error response format

type ContextLoggerKeyType added in v0.6.1

type ContextLoggerKeyType string
const ContextLoggerKey ContextLoggerKeyType = "ContextLogger"

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 []ObjectIdentifier `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 []ObjectIdentifier, errs []DeleteError) DeleteObjectsResponse

generate multi objects delete response.

type GenerateContextHandler

type GenerateContextHandler struct {
	// contains filtered or unexported fields
}

authHandler - handles all the incoming authorization headers and validates them if possible.

func (GenerateContextHandler) ServeHTTP

handler for validating incoming authorization headers.

type GetObjectResponseWriter

type GetObjectResponseWriter struct {
	// contains filtered or unexported fields
}

func (*GetObjectResponseWriter) Write

func (o *GetObjectResponseWriter) Write(p []byte) (int, error)

type HandlerFunc

type HandlerFunc func(http.Handler, *meta.Meta) http.Handler

HandlerFunc - useful to chain different middleware http.Handler

type JudgeCdnRequest

type JudgeCdnRequest func(r *http.Request) bool

type ObjectAPIHandlers

type ObjectAPIHandlers struct {
	ObjectAPI ObjectLayer
}

objectAPIHandler implements and provides http handlers for S3 API.

func (ObjectAPIHandlers) AbortMultipartUploadHandler

func (api ObjectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, r *http.Request)

AbortMultipartUploadHandler - Abort multipart upload

func (ObjectAPIHandlers) AppendObjectHandler

func (api ObjectAPIHandlers) AppendObjectHandler(w http.ResponseWriter, r *http.Request)

AppendObjectHandler - Append Object ---------- This implementation of the POST operation append an object in a bucket.

func (ObjectAPIHandlers) CompleteMultipartUploadHandler

func (api ObjectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.Request)

CompleteMultipartUploadHandler - Complete multipart upload

func (ObjectAPIHandlers) CopyObjectHandler

func (api ObjectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Request)

CopyObjectHandler - Copy Object ---------- This implementation of the PUT operation adds an object to a bucket while reading the object from another source.

func (ObjectAPIHandlers) CopyObjectPartHandler

func (api ObjectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *http.Request)

Upload part - copy

func (ObjectAPIHandlers) DelBucketLifeCycleHandler

func (api ObjectAPIHandlers) DelBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) DeleteBucketCorsHandler

func (api ObjectAPIHandlers) DeleteBucketCorsHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) DeleteBucketHandler

func (api ObjectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.Request)

DeleteBucketHandler - Delete bucket

func (ObjectAPIHandlers) DeleteBucketPolicyHandler

func (api ObjectAPIHandlers) DeleteBucketPolicyHandler(w http.ResponseWriter, r *http.Request)

DeleteBucketPolicyHandler - This HTTP handler removes bucket policy configuration.

func (ObjectAPIHandlers) DeleteBucketWebsiteHandler

func (api ObjectAPIHandlers) DeleteBucketWebsiteHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) DeleteMultipleObjectsHandler

func (api ObjectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request)

DeleteMultipleObjectsHandler - deletes multiple objects.

func (ObjectAPIHandlers) DeleteObjectHandler

func (api ObjectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.Request)

DeleteObjectHandler - delete an object

func (ObjectAPIHandlers) GetBucketAclHandler

func (api ObjectAPIHandlers) GetBucketAclHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) GetBucketCorsHandler

func (api ObjectAPIHandlers) GetBucketCorsHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) GetBucketLifeCycleHandler

func (api ObjectAPIHandlers) GetBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) GetBucketLocationHandler

func (api ObjectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request)

GetBucketLocationHandler - GET Bucket location. ------------------------- This operation returns bucket location.

func (ObjectAPIHandlers) GetBucketPolicyHandler

func (api ObjectAPIHandlers) GetBucketPolicyHandler(w http.ResponseWriter, r *http.Request)

GetBucketPolicyHandler - This HTTP handler returns bucket policy configuration.

func (ObjectAPIHandlers) GetBucketVersioningHandler

func (api ObjectAPIHandlers) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) GetBucketWebsiteHandler

func (api ObjectAPIHandlers) GetBucketWebsiteHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) GetObjectAclHandler

func (api ObjectAPIHandlers) GetObjectAclHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) GetObjectHandler

func (api ObjectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Request)

GetObjectHandler - GET Object ---------- This implementation of the GET operation retrieves object. To use GET, you must have READ access to the object.

func (ObjectAPIHandlers) HandledByWebsite

func (api ObjectAPIHandlers) HandledByWebsite(w http.ResponseWriter, r *http.Request) (handled bool)

func (ObjectAPIHandlers) HeadBucketHandler

func (api ObjectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Request)

HeadBucketHandler - HEAD Bucket ---------- This operation is useful to determine if a bucket exists. The operation returns a 200 OK if the bucket exists and you have permission to access it. Otherwise, the operation might return responses such as 404 Not Found and 403 Forbidden.

func (ObjectAPIHandlers) HeadObjectHandler

func (api ObjectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Request)

HeadObjectHandler - HEAD Object ----------- The HEAD operation retrieves metadata from an object without returning the object itself. TODO refactor HEAD and GET

func (ObjectAPIHandlers) ListBucketsHandler

func (api ObjectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.Request)

ListBucketsHandler - GET Service ----------- This implementation of the GET operation returns a list of all buckets owned by the authenticated sender of the request.

func (ObjectAPIHandlers) ListMultipartUploadsHandler

func (api ObjectAPIHandlers) ListMultipartUploadsHandler(w http.ResponseWriter, r *http.Request)

ListMultipartUploadsHandler - GET Bucket (List Multipart uploads) ------------------------- This operation lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has been initiated, using the Initiate Multipart Upload request, but has not yet been completed or aborted. This operation returns at most 1,000 multipart uploads in the response.

func (ObjectAPIHandlers) ListObjectPartsHandler

func (api ObjectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *http.Request)

ListObjectPartsHandler - List object parts

func (ObjectAPIHandlers) ListObjectsHandler

func (api ObjectAPIHandlers) ListObjectsHandler(w http.ResponseWriter, r *http.Request)

ListObjectsHandler - GET Bucket (List Objects) -- ----------------------- This implementation of the GET operation returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket.

func (ObjectAPIHandlers) ListVersionedObjectsHandler

func (api ObjectAPIHandlers) ListVersionedObjectsHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) NewMultipartUploadHandler

func (api ObjectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request)

NewMultipartUploadHandler - New multipart upload

func (ObjectAPIHandlers) PostObjectHandler

func (api ObjectAPIHandlers) PostObjectHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutBucketAclHandler

func (api ObjectAPIHandlers) PutBucketAclHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutBucketCorsHandler

func (api ObjectAPIHandlers) PutBucketCorsHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutBucketHandler

func (api ObjectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Request)

PutBucketHandler - PUT Bucket ---------- This implementation of the PUT operation creates a new bucket for authenticated request

func (ObjectAPIHandlers) PutBucketLifeCycleHandler

func (api ObjectAPIHandlers) PutBucketLifeCycleHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutBucketPolicyHandler

func (api ObjectAPIHandlers) PutBucketPolicyHandler(w http.ResponseWriter, r *http.Request)

PutBucketPolicyHandler - This HTTP handler stores given bucket policy configuration as per https://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html

func (ObjectAPIHandlers) PutBucketVersioningHandler

func (api ObjectAPIHandlers) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutBucketWebsiteHandler

func (api ObjectAPIHandlers) PutBucketWebsiteHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutObjectAclHandler

func (api ObjectAPIHandlers) PutObjectAclHandler(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutObjectHandler

func (api ObjectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Request)

PutObjectHandler - PUT Object ---------- This implementation of the PUT operation adds an object to a bucket.

func (ObjectAPIHandlers) PutObjectMeta

func (api ObjectAPIHandlers) PutObjectMeta(w http.ResponseWriter, r *http.Request)

func (ObjectAPIHandlers) PutObjectPartHandler

func (api ObjectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http.Request)

PutObjectPartHandler - Upload part

func (ObjectAPIHandlers) RenameObjectHandler

func (api ObjectAPIHandlers) RenameObjectHandler(w http.ResponseWriter, r *http.Request)

RenameObjectHandler - Rename Object ---------- Do not support bucket to enable multiVersion renaming; Folder renaming operation is not supported.

func (ObjectAPIHandlers) ReturnWebsiteErrorDocument

func (api ObjectAPIHandlers) ReturnWebsiteErrorDocument(w http.ResponseWriter, r *http.Request, statusCode int) (handled bool)

type ObjectLayer

type ObjectLayer interface {
	// Bucket operations.
	MakeBucket(bucket string, acl datatype.Acl, credential common.Credential) error
	SetBucketLifecycle(bucket string, config datatype.Lifecycle,
		credential common.Credential) error
	GetBucketLifecycle(bucket string, credential common.Credential) (datatype.Lifecycle, error)
	DelBucketLifecycle(bucket string, credential common.Credential) error
	SetBucketAcl(bucket string, policy datatype.AccessControlPolicy, acl datatype.Acl,
		credential common.Credential) error
	GetBucketAcl(bucket string, credential common.Credential) (datatype.AccessControlPolicyResponse, error)
	SetBucketCors(bucket string, cors datatype.Cors, credential common.Credential) error
	SetBucketVersioning(bucket string, versioning datatype.Versioning, credential common.Credential) error
	DeleteBucketCors(bucket string, credential common.Credential) error
	GetBucketVersioning(bucket string, credential common.Credential) (datatype.Versioning, error)
	GetBucketCors(bucket string, credential common.Credential) (datatype.Cors, error)
	GetBucket(bucketName string) (bucket *meta.Bucket, err error) // For INTERNAL USE ONLY
	GetBucketInfo(bucket string, credential common.Credential) (bucketInfo *meta.Bucket, err error)
	GetBucketInfoByCtx(ctx RequestContext, credential common.Credential) (bucket *meta.Bucket, err error)
	ListBuckets(credential common.Credential) (buckets []meta.Bucket, err error)
	DeleteBucket(bucket string, credential common.Credential) error
	ListObjects(credential common.Credential, bucket string,
		request datatype.ListObjectsRequest) (result meta.ListObjectsInfo, err error)
	ListVersionedObjects(credential common.Credential, bucket string,
		request datatype.ListObjectsRequest) (result meta.VersionedListObjectsInfo, err error)

	SetBucketPolicy(credential common.Credential, bucket string, policy policy.Policy) error
	// Policy operations
	GetBucketPolicy(credential common.Credential, bucket string) (policy.Policy, error)
	DeleteBucketPolicy(credential common.Credential, bucket string) error

	// Website operations
	SetBucketWebsite(bucket *meta.Bucket, config datatype.WebsiteConfiguration) error
	GetBucketWebsite(bucket string) (datatype.WebsiteConfiguration, error)
	DeleteBucketWebsite(bucket *meta.Bucket) error

	// Object operations.
	GetObject(object *meta.Object, startOffset int64, length int64, writer io.Writer,
		sse datatype.SseRequest) (err error)
	GetObjectInfo(bucket, object, version string, credential common.Credential) (objInfo *meta.Object, err error)
	GetObjectInfoByCtx(ctx RequestContext, version string, credential common.Credential) (objInfo *meta.Object, err error)
	PutObject(bucket, object string, credential common.Credential, size int64, data io.ReadCloser,
		metadata map[string]string, acl datatype.Acl,
		sse datatype.SseRequest, storageClass meta.StorageClass) (result datatype.PutObjectResult, err error)
	AppendObject(bucket, object string, credential common.Credential, offset uint64, size int64, data io.ReadCloser,
		metadata map[string]string, acl datatype.Acl,
		sse datatype.SseRequest, storageClass meta.StorageClass, objInfo *meta.Object) (result datatype.AppendObjectResult, err error)

	CopyObject(targetObject *meta.Object, source io.Reader, credential common.Credential,
		sse datatype.SseRequest) (result datatype.PutObjectResult, err error)
	RenameObject(targetObject *meta.Object, sourceObject string, credential common.Credential) (result datatype.RenameObjectResult, err error)
	PutObjectMeta(bucket *meta.Bucket, targetObject *meta.Object, credential common.Credential) (err error)
	SetObjectAcl(bucket string, object string, version string, policy datatype.AccessControlPolicy,
		acl datatype.Acl, credential common.Credential) error
	GetObjectAcl(bucket string, object string, version string, credential common.Credential) (
		policy datatype.AccessControlPolicyResponse, err error)
	DeleteObject(bucket, object, version string, credential common.Credential) (datatype.DeleteObjectResult,
		error)

	// Multipart operations.
	ListMultipartUploads(credential common.Credential, bucket string,
		request datatype.ListUploadsRequest) (result datatype.ListMultipartUploadsResponse, err error)
	NewMultipartUpload(credential common.Credential, bucket, object string,
		metadata map[string]string, acl datatype.Acl,
		sse datatype.SseRequest, storageClass meta.StorageClass) (uploadID string, err error)
	PutObjectPart(bucket, object string, credential common.Credential, uploadID string, partID int,
		size int64, data io.ReadCloser, md5Hex string,
		sse datatype.SseRequest) (result datatype.PutObjectPartResult, err error)
	CopyObjectPart(bucketName, objectName, uploadId string, partId int, size int64, data io.Reader,
		credential common.Credential, sse datatype.SseRequest) (result datatype.PutObjectResult,
		err error)
	ListObjectParts(credential common.Credential, bucket, object string,
		request datatype.ListPartsRequest) (result datatype.ListPartsResponse, err error)
	AbortMultipartUpload(credential common.Credential, bucket, object, uploadID string) error
	CompleteMultipartUpload(credential common.Credential, bucket, object, uploadID string,
		uploadedParts []meta.CompletePart) (result datatype.CompleteMultipartResult, err error)
}

ObjectLayer implements primitives for object API layer.

type Replacer

type Replacer interface {
	Replace(string) string
	Set(key, value string)
	GetReplacedValues() map[string]string
}

Replacer is a type which can replace placeholder substrings in a string with actual values from a http.Request and ResponseRecorder. Always use NewReplacer to get one of these. Any placeholders made with Set() should overwrite existing values if the key is already used.

func NewReplacer

func NewReplacer(r *http.Request, rr *ResponseRecorder, emptyValue string) Replacer

NewReplacer makes a new replacer based on r and rr which are used for request and response placeholders, respectively. Request placeholders are created immediately, whereas response placeholders are not created until Replace() is invoked. rr may be nil if it is not available. emptyValue should be the string that is used in place of empty string (can still be empty string).

type RequestContext added in v0.6.1

type RequestContext struct {
	RequestID      string
	Logger         log.Logger
	BucketName     string
	ObjectName     string
	BucketInfo     *types.Bucket
	ObjectInfo     *types.Object
	AuthType       signature.AuthType
	IsBucketDomain bool
}

type RequestContextKeyType added in v0.6.1

type RequestContextKeyType string
const RequestContextKey RequestContextKeyType = "RequestContext"

type RequestIdHandler

type RequestIdHandler struct {
	// contains filtered or unexported fields
}

func (RequestIdHandler) ServeHTTP

func (h RequestIdHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RequestIdKeyType added in v0.6.1

type RequestIdKeyType string
const RequestIdKey RequestIdKeyType = "RequestID"

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewResponseRecorder

func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder

func (*ResponseRecorder) Flush

func (r *ResponseRecorder) Flush()

type Server

type Server struct {
	Server *http.Server
}

func (*Server) Stop

func (s *Server) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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