api

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S3ErrAccessDenied         = "AccessDenied"
	S3ErrBucketAlreadyExists  = "BucketAlreadyOwnedByYou"
	S3ErrBucketNotEmpty       = "BucketNotEmpty"
	S3ErrInternalError        = "InternalError"
	S3ErrInvalidArgument      = "InvalidArgument"
	S3ErrInvalidBucketName    = "InvalidBucketName"
	S3ErrNoSuchBucket         = "NoSuchBucket"
	S3ErrNoSuchKey            = "NoSuchKey"
	S3ErrMethodNotAllowed     = "MethodNotAllowed"
	S3ErrMissingContentLength = "MissingContentLength"
)

S3 error codes

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketStatsResponse

type BucketStatsResponse struct {
	Bucket         string `json:"bucket"`
	ObjectCount    int64  `json:"object_count"`
	TotalSizeBytes int64  `json:"total_size_bytes"`
}

BucketStatsResponse is returned by GET /_stats/{name}.

type CompleteMultipartUploadInput

type CompleteMultipartUploadInput struct {
	XMLName xml.Name       `xml:"CompleteMultipartUpload"`
	Parts   []CompletePart `xml:"Part"`
}

CompleteMultipartUploadInput is the XML request for CompleteMultipartUpload.

type CompleteMultipartUploadResult

type CompleteMultipartUploadResult struct {
	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
	XMLNS    string   `xml:"xmlns,attr"`
	Location string   `xml:"Location"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	ETag     string   `xml:"ETag"`
}

CompleteMultipartUploadResult is the XML response for CompleteMultipartUpload.

type CompletePart

type CompletePart struct {
	PartNumber int    `xml:"PartNumber"`
	ETag       string `xml:"ETag"`
}

type CopyObjectResult

type CopyObjectResult struct {
	XMLName      xml.Name `xml:"CopyObjectResult"`
	XMLNS        string   `xml:"xmlns,attr"`
	LastModified string   `xml:"LastModified"`
	ETag         string   `xml:"ETag"`
}

CopyObjectResult is the XML response for CopyObject.

type Handler

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

Handler is the S3-compatible HTTP handler.

func NewHandler

func NewHandler(db *meta.DB, st *store.Store, au *auth.Auth, log *slog.Logger, metrics *maintenance.Metrics, signingSecret string, rlCfg *RateLimiterConfig) *Handler

NewHandler creates a new S3 API handler.

trustProxyHeaders defaults to false (the safe option). Callers that sit behind a trusted reverse proxy should call SetTrustProxyHeaders(true) after construction — typically wired from cfg.TrustProxyHeaders in main.go. This is kept as a setter (not an extra NewHandler arg) so main.go's existing NewHandler call site does not need to be modified by this refactor agent.

func (*Handler) ServeHTTP

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

ServeHTTP dispatches S3 requests based on path and method.

func (*Handler) SetTrustProxyHeaders

func (h *Handler) SetTrustProxyHeaders(v bool)

SetTrustProxyHeaders enables or disables trust in X-Forwarded-For for client-IP derivation. Must be called before the server begins accepting requests — there is no locking around the flag. When false (the default), X-Forwarded-For is ignored entirely. When true, X-Forwarded-For is honoured only if the direct TCP peer is loopback or RFC1918 private.

type InitiateMultipartUploadResult

type InitiateMultipartUploadResult struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	XMLNS    string   `xml:"xmlns,attr"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadId string   `xml:"UploadId"`
}

InitiateMultipartUploadResult is the XML response for CreateMultipartUpload.

type ListAllMyBucketsResult

type ListAllMyBucketsResult struct {
	XMLName xml.Name     `xml:"ListAllMyBucketsResult"`
	XMLNS   string       `xml:"xmlns,attr"`
	Owner   S3Owner      `xml:"Owner"`
	Buckets S3BucketList `xml:"Buckets"`
}

ListAllMyBucketsResult is the XML response for listing buckets.

type ListBucketResult

type ListBucketResult struct {
	XMLName               xml.Name         `xml:"ListBucketResult"`
	XMLNS                 string           `xml:"xmlns,attr"`
	Name                  string           `xml:"Name"`
	Prefix                string           `xml:"Prefix"`
	Delimiter             string           `xml:"Delimiter,omitempty"`
	MaxKeys               int              `xml:"MaxKeys"`
	IsTruncated           bool             `xml:"IsTruncated"`
	Contents              []S3Content      `xml:"Contents"`
	CommonPrefixes        []S3CommonPrefix `xml:"CommonPrefixes,omitempty"`
	KeyCount              int              `xml:"KeyCount"`
	EncodingType          string           `xml:"EncodingType,omitempty"`
	StartAfter            string           `xml:"StartAfter,omitempty"`
	ContinuationToken     string           `xml:"ContinuationToken,omitempty"`
	NextContinuationToken string           `xml:"NextContinuationToken,omitempty"`
}

ListBucketResult is the XML response for ListObjectsV2.

type ListPartsResult

type ListPartsResult struct {
	XMLName  xml.Name `xml:"ListPartsResult"`
	XMLNS    string   `xml:"xmlns,attr"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadId string   `xml:"UploadId"`
	Parts    []S3Part `xml:"Part"`
}

ListPartsResult is the XML response for ListParts.

type RateLimiterConfig

type RateLimiterConfig struct {
	Rate  float64 // requests per second per token (0 = disabled)
	Burst int     // maximum burst size
}

RateLimiterConfig is retained for backward compatibility with existing main.go wiring. It is a thin alias over internal/ratelimit.Config.

type S3BucketEntry

type S3BucketEntry struct {
	Name         string `xml:"Name"`
	CreationDate string `xml:"CreationDate"`
}

type S3BucketList

type S3BucketList struct {
	Bucket []S3BucketEntry `xml:"Bucket"`
}

type S3CommonPrefix

type S3CommonPrefix struct {
	Prefix string `xml:"Prefix"`
}

type S3Content

type S3Content struct {
	Key          string `xml:"Key"`
	LastModified string `xml:"LastModified"`
	ETag         string `xml:"ETag"`
	Size         int64  `xml:"Size"`
	StorageClass string `xml:"StorageClass"`
}

type S3Error

type S3Error struct {
	XMLName   xml.Name `xml:"Error"`
	Code      string   `xml:"Code"`
	Message   string   `xml:"Message"`
	Resource  string   `xml:"Resource"`
	RequestID string   `xml:"RequestId"`
}

S3Error represents an S3 XML error response.

type S3Owner

type S3Owner struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
}

type S3Part

type S3Part struct {
	PartNumber   int    `xml:"PartNumber"`
	LastModified string `xml:"LastModified"`
	ETag         string `xml:"ETag"`
	Size         int64  `xml:"Size"`
}

Jump to

Keyboard shortcuts

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