middleware

package
v0.0.0-...-32f2820 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FP_INVALID = iota
	FP_ERROR
	FP_EXPIRED
	FP_SCOPE_ACCOUNT
	FP_SCOPE_CONTAINER
)
View Source
const (
	SCOPE_INVALID = iota
	SCOPE_ACCOUNT
	SCOPE_CONTAINER
)
View Source
const (
	DELETE_MARKER_CONTENT_TYPE = "application/x-deleted;swift_versions_deleted=1"
	CLIENT_VERSIONS_LOC        = "X-Versions-Location"
	CLIENT_HISTORY_LOC         = "X-History-Location"
	SYSMETA_VERSIONS_LOC       = "X-Container-Sysmeta-Versions-Location"
	SYSMETA_VERSIONS_MODE      = "X-Container-Sysmeta-Versions-Mode"
)

Variables

View Source
var S3Subresources = map[string]bool{
	"acl":                          true,
	"delete":                       true,
	"lifecycle":                    true,
	"location":                     true,
	"logging":                      true,
	"notification":                 true,
	"partNumber":                   true,
	"policy":                       true,
	"requestPayment":               true,
	"torrent":                      true,
	"uploads":                      true,
	"uploadId":                     true,
	"versionId":                    true,
	"versioning":                   true,
	"versions":                     true,
	"website":                      true,
	"response-cache-control":       true,
	"response-content-disposition": true,
	"response-content-encoding":    true,
	"response-content-language":    true,
	"response-content-type":        true,
	"response-expires":             true,
	"cors":                         true,
	"tagging":                      true,
	"restore":                      true,
}

Functions

func AuthorizeUnconfirmedIdentity

func AuthorizeUnconfirmedIdentity(r *http.Request, obj string, referrers []string, roles []string) (bool, error)

func BucketAlreadyExistsResponse

func BucketAlreadyExistsResponse(writer http.ResponseWriter, request *http.Request)

func CleanACL

func CleanACL(name string, value string) (string, error)

Returns a cleaned ACL header value, validating that it meets the formatting requirements for standard Hummingbird ACL strings.

func CopyItems

func CopyItems(dest, src http.Header)

TODO: This seems like it might copy headers it shouldn't. Also, shouldn't it be called copyHeaders instead?

func CopyItemsExclude

func CopyItemsExclude(dest, src http.Header, exclude []string)

func InvalidBucketNameResponse

func InvalidBucketNameResponse(writer http.ResponseWriter, request *http.Request)

func NewAccountQuota

func NewAccountQuota(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewAuthToken

func NewAuthToken(section conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewBulk

func NewBulk(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewCaptureWriter

func NewCaptureWriter() *captureWriter

func NewCatchError

func NewCatchError(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewContainerQuota

func NewContainerQuota(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewContext

func NewContext(debugResponses bool, mc ring.MemcacheRing, log srv.LowLevelLogger, proxyClientFactory client.ProxyClient) func(http.Handler) http.Handler

func NewCopyMiddleware

func NewCopyMiddleware(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewCors

func NewCors(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewCrossDomain

func NewCrossDomain(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewFormPost

func NewFormPost(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewHealthcheck

func NewHealthcheck(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewKeystoneAuth

func NewKeystoneAuth(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewMultirange

func NewMultirange(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

NewMultirange returns an instance of the multirange middleware with the given config.

This middleware intercepts object GET requests with multiple ranges in the Range header and turns them into separate single-range requests on the backend, combining them into a multipart response. This should simplify the implementation of things like xLO and the object server.

func NewRatelimiter

func NewRatelimiter(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewRequestLogger

func NewRequestLogger(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewS3Api

func NewS3Api(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewS3Auth

func NewS3Auth(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewS3BucketList

func NewS3BucketList() *s3BucketList

func NewS3Error

func NewS3Error() *s3Error

func NewS3ObjectList

func NewS3ObjectList(ver string) s3ObjectList

func NewStaticWeb

func NewStaticWeb(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewTempAuth

func NewTempAuth(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewTempURL

func NewTempURL(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewVersionedWrites

func NewVersionedWrites(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NewXlo

func NewXlo(config conf.Section, metricsScope tally.Scope) (func(http.Handler) http.Handler, error)

func NoSuchBucketResponse

func NoSuchBucketResponse(writer http.ResponseWriter, request *http.Request)

func NoSuchKeyResponse

func NoSuchKeyResponse(writer http.ResponseWriter, request *http.Request)

func ParseACL

func ParseACL(acl string) ([]string, []string)

Parses a standard Hummingbird ACL string into a referrers list and groups list.

func PipedGet

func PipedGet(urlStr string, request *http.Request, source string, auth AuthorizeFunc) (io.ReadCloser, http.Header, int)

func Recover

func Recover(w http.ResponseWriter, r *http.Request, msg string, recoversMetric tally.Counter)

func ReferrerAllowed

func ReferrerAllowed(referrer string, referrerACL []string) bool

Returns True if the referrer should be allowed based on the referrerACL list

func RegisterInfo

func RegisterInfo(name string, data interface{})

func RemoveItemsWithPrefix

func RemoveItemsWithPrefix(header http.Header, prefix string)

func SignatureDoesNotMatchResponse

func SignatureDoesNotMatchResponse(writer http.ResponseWriter, request *http.Request)

Types

type AccountInfo

type AccountInfo struct {
	ContainerCount int64
	ObjectCount    int64
	ObjectBytes    int64
	Metadata       map[string]string
	SysMetadata    map[string]string
	StatusCode     int `json:"status"`
}

type AuthorizeFunc

type AuthorizeFunc func(r *http.Request) (bool, int)

type CopyWriter

type CopyWriter struct {
	http.ResponseWriter
	Logger srv.LowLevelLogger
	// contains filtered or unexported fields
}

func (*CopyWriter) WriteHeader

func (cw *CopyWriter) WriteHeader(status int)

type ObjectListingRecord

type ObjectListingRecord struct {
	Name         string `json:"name"`
	LastModified string `json:"last_modified"`
	Size         int64  `json:"bytes"`
	ContentType  string `json:"content_type"`
	ETag         string `json:"hash"`
	Subdir       string `json:"subdir"`
}

type PipeResponseWriter

type PipeResponseWriter struct {
	Logger srv.LowLevelLogger
	// contains filtered or unexported fields
}

func NewPipeResponseWriter

func NewPipeResponseWriter(writer *io.PipeWriter, ready chan struct{}, logger srv.LowLevelLogger) *PipeResponseWriter

func (*PipeResponseWriter) Close

func (w *PipeResponseWriter) Close()

func (*PipeResponseWriter) Header

func (w *PipeResponseWriter) Header() http.Header

func (*PipeResponseWriter) Write

func (w *PipeResponseWriter) Write(stuff []byte) (int, error)

func (*PipeResponseWriter) WriteHeader

func (w *PipeResponseWriter) WriteHeader(status int)

type ProxyContext

type ProxyContext struct {
	*ProxyContextMiddleware
	C               client.RequestClient
	Authorize       AuthorizeFunc
	RemoteUsers     []string
	StorageOwner    bool
	ResellerRequest bool
	ACL             string

	Logger *zap.Logger
	TxId   string

	Source string
	S3Auth *S3AuthInfo
	// contains filtered or unexported fields
}

func GetProxyContext

func GetProxyContext(r *http.Request) *ProxyContext

func (*ProxyContext) AutoCreateAccount

func (pc *ProxyContext) AutoCreateAccount(ctx context.Context, account string, headers http.Header)

func (*ProxyContext) GetAccountInfo

func (pc *ProxyContext) GetAccountInfo(ctx context.Context, account string) (*AccountInfo, error)

func (*ProxyContext) InvalidateAccountInfo

func (pc *ProxyContext) InvalidateAccountInfo(ctx context.Context, account string)

func (*ProxyContext) Response

func (ctx *ProxyContext) Response() (time.Time, int)

type ProxyContextMiddleware

type ProxyContextMiddleware struct {
	Cache ring.MemcacheRing
	// contains filtered or unexported fields
}

func (*ProxyContextMiddleware) ServeHTTP

func (m *ProxyContextMiddleware) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type S3AuthInfo

type S3AuthInfo struct {
	Key          string
	Signature    string
	StringToSign string
	Account      string
}

type VersionedContainerWriter

type VersionedContainerWriter struct {
	http.ResponseWriter
}

func (*VersionedContainerWriter) WriteHeader

func (vcw *VersionedContainerWriter) WriteHeader(status int)

type VersionedObjectWriter

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

func NewVersionedObjectWriter

func NewVersionedObjectWriter() *VersionedObjectWriter

func (*VersionedObjectWriter) Header

func (vow *VersionedObjectWriter) Header() http.Header

func (*VersionedObjectWriter) Write

func (vow *VersionedObjectWriter) Write(stuff []byte) (int, error)

func (*VersionedObjectWriter) WriteHeader

func (vow *VersionedObjectWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

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