Documentation
¶
Overview ¶
Package server 实现 filex 自研对象存储协议的 HTTP 处理器, 可直接挂载到 net/http 或 webx。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuditEvent ¶ added in v0.5.0
type AuditEvent struct {
RequestID string
Method string
Path string
Subject string
Status int
At time.Time
}
AuditEvent 是审计事件。
type HandlerConfig ¶
type HandlerConfig struct {
// Store 是底层存储引擎(必填),*filex.Store 可直接使用。
Store Store
// Logger 是可选结构化日志。
Logger filex.Logger
// Token 设置后要求 Authorization: Bearer <Token>。
Token string
// Authenticate 是可选鉴权回调;返回错误则拒绝请求。
Authenticate func(r *http.Request) error
// HMACSecret 设置后要求 X-Filex-Signature 请求签名。
HMACSecret []byte
// Audit 是可选审计回调。
Audit func(AuditEvent)
// Metrics 是可选请求指标。
Metrics filex.Metrics
}
HandlerConfig 是协议处理器的配置。
type Store ¶
type Store interface {
CreateBucket(ctx context.Context, name string) (filex.BucketInfo, error)
DeleteBucket(ctx context.Context, name string) error
HeadBucket(ctx context.Context, name string) (filex.BucketInfo, error)
ListBuckets(ctx context.Context) ([]filex.BucketInfo, error)
Put(ctx context.Context, bucket, key string, r io.Reader, opts filex.PutOptions) (filex.ObjectInfo, error)
Get(ctx context.Context, bucket, key string, opts filex.GetOptions) (*filex.Object, error)
Head(ctx context.Context, bucket, key string) (filex.ObjectInfo, error)
Delete(ctx context.Context, bucket, key string) error
List(ctx context.Context, bucket string, opts filex.ListOptions) (filex.ListResult, error)
InitiateMultipartUpload(ctx context.Context, bucket, key string, opts filex.PutOptions) (filex.UploadInfo, error)
UploadPart(ctx context.Context, bucket, key, uploadID string, partNumber int, r io.Reader) (filex.PartInfo, error)
CompleteMultipartUpload(ctx context.Context, bucket, key, uploadID string) (filex.ObjectInfo, error)
AbortMultipartUpload(ctx context.Context, bucket, key, uploadID string) error
ListParts(ctx context.Context, bucket, key, uploadID string) ([]filex.PartInfo, error)
SetBucketVersioning(ctx context.Context, name string, enabled bool) (filex.BucketInfo, error)
SetBucketQuota(ctx context.Context, name string, quota int64) (filex.BucketInfo, error)
GetVersion(ctx context.Context, bucket, key, versionID string, opts filex.GetOptions) (*filex.Object, error)
HeadVersion(ctx context.Context, bucket, key, versionID string) (filex.ObjectInfo, error)
DeleteVersion(ctx context.Context, bucket, key, versionID string) error
RestoreVersion(ctx context.Context, bucket, key, versionID string) (filex.ObjectInfo, error)
ListVersions(ctx context.Context, bucket, key string) ([]filex.ObjectInfo, error)
Copy(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string) (filex.ObjectInfo, error)
Move(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string) (filex.ObjectInfo, error)
Health(ctx context.Context) error
}
Store 是协议处理器所需的存储引擎接口,*filex.Store 天然满足。
Click to show internal directories.
Click to hide internal directories.