import "secondbit.org/gifs/api"
const (
DefaultTokenURI = "https://accounts.google.com/o/oauth2/token"
DefaultListenAddr = ":8080"
AuthHeader = "Gifs-Username"
)
var (
BucketNotFoundError = errors.New("bucket not found")
BlobNotFoundError = errors.New("blob not found")
)
var (
CollectionNotFoundError = errors.New("collection not found")
)
var (
InvalidBearerToken = errors.New("Invalid bearer token")
)
func CollectionList(w http.ResponseWriter, r *http.Request, c Context)
func CreateCollection(w http.ResponseWriter, r *http.Request, c Context)
func GetBlob(w http.ResponseWriter, r *http.Request, c Context)
func GetDomainMuxer(c Context) *mux.Router
func GetPathMuxer(c Context) *mux.Router
func Upload(id, collection, tag string, r io.Reader, c Context) (string, error)
func UploadHandler(w http.ResponseWriter, r *http.Request, c Context)
type Authorizer interface {
Authorize(token string, c Context) (string, error)
}
type Bucket map[string][]byte
type Collection struct {
Items map[string]Item
Name string
Slug string
}
type Context struct {
Storage Storage
Datastore Datastore
UsageTracker *UsageTracker
Authorizer Authorizer
Bucket string
RootDomain string
}
type Datastore interface {
Init(dbName string) error
CreateCollection(slug, name string) (Collection, error)
UpdateCollection(slug, name string) error
GetCollectionData(slug string) (Collection, error)
GetCollectionItems(slug string) (map[string]Item, error)
AddItemToCollection(slug string, item Item) error
GetItemFromCollection(slug, tag string) (Item, error)
}
func NewMemDatastore() Datastore
func NewMySQLDatastore(dsn string) (Datastore, error)
type GoogleCloudStorage struct {
*storage.Service
}
func (gcs *GoogleCloudStorage) Delete(bucket, tmp string) error
func (gcs *GoogleCloudStorage) Download(bucket, id string, w io.Writer, c Context) (int64, error)
func (gcs *GoogleCloudStorage) Move(srcBucket, src, dstBucket, dst string, c Context) error
func (gcs *GoogleCloudStorage) Upload(bucket, tmp string, r io.Reader, c Context, errs chan error, done chan struct{})
type GoogleOAuth2Authorizer struct {
ClientID string
sync.Mutex
// contains filtered or unexported fields
}
func NewGoogleOAuth2Authorizer(id string) *GoogleOAuth2Authorizer
func (g *GoogleOAuth2Authorizer) Authorize(token string, c Context) (string, error)
type Handler func(w http.ResponseWriter, r *http.Request, c Context)
type Item struct {
Blob string
Bucket string
Tag string
}
type Memstorage map[string]Bucket
func (m Memstorage) Delete(bucket, tmp string) error
func (m Memstorage) Download(bucket, id string, w io.Writer, c Context) (int64, error)
func (m Memstorage) Move(srcBucket, src, dstBucket, dst string, c Context) error
func (m Memstorage) Upload(bucket, tmp string, r io.Reader, c Context, errs chan error, done chan struct{})
type Memstore map[string]*Collection
func (m Memstore) AddItemToCollection(slug string, item Item) error
func (m Memstore) CreateCollection(slug, name string) (Collection, error)
func (m Memstore) GetCollectionData(slug string) (Collection, error)
func (m Memstore) GetCollectionItems(slug string) (map[string]Item, error)
func (m Memstore) GetItemFromCollection(slug, tag string) (Item, error)
func (m Memstore) Init(dbName string) error
func (m Memstore) UpdateCollection(slug, name string) error
type SQLStore sql.DB
func (s *SQLStore) AddItemToCollection(slug string, item Item) error
func (s *SQLStore) CreateCollection(slug, name string) (Collection, error)
func (s *SQLStore) GetCollectionData(slug string) (Collection, error)
func (s *SQLStore) GetCollectionItems(slug string) (map[string]Item, error)
func (s *SQLStore) GetItemFromCollection(slug, tag string) (Item, error)
func (s *SQLStore) Init(name string) error
func (s *SQLStore) UpdateCollection(slug, name string) error
type Storage interface {
Upload(bucket, tmp string, r io.Reader, c Context, errs chan error, done chan struct{})
Delete(bucket, tmp string) error
Move(srcBucket, src, dstBucket, dst string, c Context) error
Download(bucket, id string, w io.Writer, c Context) (int64, error)
}
func NewGCSStorage(gcsClientEmail, gcsTokenURI string, gcsPemBytes []byte) (Storage, error)
func NewMemStorage() Storage
type Usage struct {
UploadedBytes int64
UploadBytesChan chan int64
DownloadedBytes int64
DownloadBytesChan chan int64
UploadRequests int64
UploadRequestsChan chan int64
DownloadRequests int64
DownloadRequestsChan chan int64
}
type UsageTracker struct {
sync.Mutex
// contains filtered or unexported fields
}
func NewUsageTracker() *UsageTracker
func (u *UsageTracker) TrackDownloads(id string) (bytes, requests chan int64)
func (u *UsageTracker) TrackUploads(id string) (bytes, requests chan int64)
Generated by godoc2md