Documentation ¶
Overview ¶
Package weasel provides means for serving content from a Google Cloud Storage (GCS) bucket, suitable for hosting on Google App Engine. See README.md for the design details.
This package is a work in progress and makes no API stability promises.
Index ¶
- Variables
- func ValidMethod(m string) bool
- type CORS
- type FetchError
- type Object
- type Storage
- func (s *Storage) CacheKey(bucket, name string) string
- func (s *Storage) HandleChangeHook(w http.ResponseWriter, r *http.Request)
- func (s *Storage) Open(ctx context.Context, bucket, name string) (*Object, error)
- func (s *Storage) OpenFile(ctx context.Context, bucket, name string) (*Object, error)
- func (s *Storage) PurgeCache(ctx context.Context, bucket, name string) error
- func (s *Storage) ServeObject(w http.ResponseWriter, r *http.Request, o *Object) error
- func (s *Storage) Stat(ctx context.Context, bucket, name string) (*Object, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultStorage = &Storage{ Base: "https://storage.googleapis.com", Index: "index.html", CORS: CORS{ Origin: []string{"*"}, MaxAge: "86400", }, }
DefaultStorage is a Storage with sensible default parameters.
Functions ¶
func ValidMethod ¶
ValidMethod reports whether m is a supported HTTP method.
Types ¶
type CORS ¶
type CORS struct { Origin []string // allowed origins MaxAge string // preflight cache, in seconds }
CORS is a Storage cross-origin settings.
type FetchError ¶
FetchError contains error code and message from a GCS response.
type Object ¶
type Object struct { Meta map[string]string Body io.ReadCloser }
Object represents a single GCS object.
func (*Object) RedirectCode ¶
RedirectCode returns o's HTTP response code for redirect. It defaults to http.StatusMovedPermanently.
type Storage ¶
type Storage struct { Base string // GCS service base URL, e.g. "https://storage.googleapis.com". Index string // Appended to an object name in certain cases, e.g. "index.html". CORS CORS }
Storage incapsulates configuration params for retrieveing and serving GCS objects.
func (*Storage) CacheKey ¶
CacheKey returns a key to cache an object under, computed from s.Base, bucket and then name.
func (*Storage) HandleChangeHook ¶
func (s *Storage) HandleChangeHook(w http.ResponseWriter, r *http.Request)
HandleChangeHook handles Object Change Notifications as described at https://cloud.google.com/storage/docs/object-change-notification. It removes objects from cache.
func (*Storage) Open ¶
Open retrieves GCS object name of the bucket from cache or network. Objects fetched from the network are cached before returning from this function.
func (*Storage) PurgeCache ¶
PurgeCache removes cached object from memcache. It does not return an error in the case of cache miss.
func (*Storage) ServeObject ¶
ServeObject writes object o to w, with optional body and CORS headers, based on the in-flight request r.
Directories ¶
Path | Synopsis |
---|---|
Package internal contains utilities internal to the weasel packages.
|
Package internal contains utilities internal to the weasel packages. |
Package server provides a simple frontend in form of an App Engine app built atop the weasel.Storage.
|
Package server provides a simple frontend in form of an App Engine app built atop the weasel.Storage. |