chame

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultContentType = []string{
	"image/bmp",
	"image/cgm",
	"image/g3fax",
	"image/gif",
	"image/ief",
	"image/jp2",
	"image/jpeg",
	"image/jpg",
	"image/pict",
	"image/png",
	"image/prs.btif",
	"image/svg+xml",
	"image/tiff",
	"image/vnd.adobe.photoshop",
	"image/vnd.djvu",
	"image/vnd.dwg",
	"image/vnd.dxf",
	"image/vnd.fastbidsheet",
	"image/vnd.fpx",
	"image/vnd.fst",
	"image/vnd.fujixerox.edmics-mmr",
	"image/vnd.fujixerox.edmics-rlc",
	"image/vnd.microsoft.icon",
	"image/vnd.ms-modi",
	"image/vnd.net-fpx",
	"image/vnd.wap.wbmp",
	"image/vnd.xiff",
	"image/webp",
	"image/x-cmu-raster",
	"image/x-cmx",
	"image/x-icon",
	"image/x-macpaint",
	"image/x-pcx",
	"image/x-pict",
	"image/x-portable-anymap",
	"image/x-portable-bitmap",
	"image/x-portable-graymap",
	"image/x-portable-pixmap",
	"image/x-quicktime",
	"image/x-rgb",
	"image/x-xbitmap",
	"image/x-xpixmap",
	"image/x-xwindowdump",
}

DefaultContentType is the default value of Chame.ContentType. These values are taken from https://github.com/atmos/camo/blob/bd731cff64fd61a7ee4ea7dd6e96b8e0b69c3da0/mime-types.json DefaultContentType is provided for only documentation purpose and modifying it has no effect.

View Source
var DefaultHTTPClient = &http.Client{
	Transport: http.DefaultTransport,
	Timeout:   30 * time.Second,
}

Functions

func CopyRequestHeaders

func CopyRequestHeaders(dest *http.Request, src *http.Request)

Deprecated. This method is mainly for internal use and is no longer used internally.

func CopyResponseHeaders

func CopyResponseHeaders(w http.ResponseWriter, resp *http.Response)

Deprecated. This method is mainly for internal use and is no longer used internally.

func DecodeToken

func DecodeToken(_ context.Context, store Store, tokenString string) (string, error)

func EncodeToken

func EncodeToken(ctx context.Context, store Store, token *Token, kid string) (string, error)

func IsAcceptableContentType

func IsAcceptableContentType(ctype string) bool

Deprecated. This method is mainly for internal use and is no longer used internally.

func JWTEpoch

func JWTEpoch(unix int64) *jwt.NumericDate

func New deprecated

func New(cfg *Config) http.Handler

Deprecated: Instantiate Chame directly.

Types

type Chame

type Chame struct {
	Proxy Proxy
	Store Store

	// ContentType is a list of Content-Type values allowed to be proxied. If
	// ContentType is nil, DefaultContentType will be used.
	ContentType []string
	// ExtraContentType is a list of Content-Type values allowed to be proxied
	// alongside ContentType. In contrast to ContentType, ExtraContentType
	// does not override the default list.
	ExtraContentType []string
	// contains filtered or unexported fields
}

func (*Chame) ServeHTTP added in v1.4.0

func (chame *Chame) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Chame) ServeHome

func (chame *Chame) ServeHome(w http.ResponseWriter, req *http.Request)

func (*Chame) ServeProxy

func (chame *Chame) ServeProxy(w http.ResponseWriter, userReq *http.Request)

type Client added in v1.2.0

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

func NewClient added in v1.2.0

func NewClient(baseUrl string, issuer string, store Store) (*Client, error)

func (*Client) BaseURL added in v1.6.0

func (cli *Client) BaseURL() string

func (*Client) Sign added in v1.2.0

func (cli *Client) Sign(ctx context.Context, url string, opts SignOption) (string, error)

type Config deprecated

type Config struct {
	Store Store
	Proxy Proxy
	// List of Content-Type to be proxied. If nil, DefaultProxyContent will be
	// used.
	ProxyContentType []string
	// Deprecated. Use HTTPProxy with HTTPClient set on Proxy field above.
	NewHTTPClient func(context.Context) *http.Client
	// contains filtered or unexported fields
}

Deprecated: Initialize Chame directly.

func (*Config) UseInterceptor

func (cfg *Config) UseInterceptor(iceptor func(http.Handler) http.Handler)

type HTTPProxy added in v1.1.0

type HTTPProxy struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func (*HTTPProxy) Do added in v1.1.0

func (f *HTTPProxy) Do(w http.ResponseWriter, userReq *ProxyRequest)

type Proxy added in v1.1.0

type Proxy interface {
	Do(http.ResponseWriter, *ProxyRequest)
}

type ProxyRequest added in v1.1.0

type ProxyRequest struct {
	Context context.Context
	URL     *url.URL
	Header  http.Header
}

type RawHeader added in v1.4.0

type RawHeader interface {
	RawHeader() http.Header
}

type SignOption added in v1.2.0

type SignOption struct {
	JwtKid    string
	NotBefore time.Time
	NotAfter  time.Time

	// Deprecated: use NotAfter
	Expiry time.Time
}

type Store

type Store interface {
	// GetVerifyingKey retrieves a key would be used to verify signed URLs by
	// a combination of Issuer (the "iss" claim) and Key ID (the "kid" header
	// value).
	// If an appropriate key is found, GetVerifyingKey returns a non-nil key
	// (the its type must be []byte for HMAC, *rsa.Publickey for RSA, or
	// *ecdsa.PublicKey for ECDSA) as the first return value, and nil err as
	// the second return value.
	// Otherwise GetVerifyingKey returns non-nil err as the second.
	GetVerifyingKey(iss string, kid string) (key interface{}, err error)

	GetSigningKey(iss string, kid string) (key interface{}, err error)
}

type Token

type Token = jwt.RegisteredClaims

Jump to

Keyboard shortcuts

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