GithubHelp home page GithubHelp logo

gifs-api's Introduction

api

import "secondbit.org/gifs/api"

Constants

const (
    DefaultTokenURI   = "https://accounts.google.com/o/oauth2/token"
    DefaultListenAddr = ":8080"
    AuthHeader        = "Gifs-Username"
)

Variables

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

func CollectionList(w http.ResponseWriter, r *http.Request, c Context)

func CreateCollection

func CreateCollection(w http.ResponseWriter, r *http.Request, c Context)

func GetBlob

func GetBlob(w http.ResponseWriter, r *http.Request, c Context)

func GetDomainMuxer

func GetDomainMuxer(c Context) *mux.Router

func GetPathMuxer

func GetPathMuxer(c Context) *mux.Router

func Upload

func Upload(id, collection, tag string, r io.Reader, c Context) (string, error)

func UploadHandler

func UploadHandler(w http.ResponseWriter, r *http.Request, c Context)

type Authorizer

type Authorizer interface {
    Authorize(token string, c Context) (string, error)
}

type Bucket

type Bucket map[string][]byte

type Collection

type Collection struct {
    Items map[string]Item
    Name  string
    Slug  string
}

type Context

type Context struct {
    Storage      Storage
    Datastore    Datastore
    UsageTracker *UsageTracker
    Authorizer   Authorizer
    Bucket       string
    RootDomain   string
}

type Datastore

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

func NewMemDatastore() Datastore

func NewMySQLDatastore

func NewMySQLDatastore(dsn string) (Datastore, error)

type GoogleCloudStorage

type GoogleCloudStorage struct {
    *storage.Service
}

func (*GoogleCloudStorage) Delete

func (gcs *GoogleCloudStorage) Delete(bucket, tmp string) error

func (*GoogleCloudStorage) Download

func (gcs *GoogleCloudStorage) Download(bucket, id string, w io.Writer, c Context) (int64, error)

func (*GoogleCloudStorage) Move

func (gcs *GoogleCloudStorage) Move(srcBucket, src, dstBucket, dst string, c Context) error

func (*GoogleCloudStorage) Upload

func (gcs *GoogleCloudStorage) Upload(bucket, tmp string, r io.Reader, c Context, errs chan error, done chan struct{})

type GoogleOAuth2Authorizer

type GoogleOAuth2Authorizer struct {
    ClientID string

    sync.Mutex
    // contains filtered or unexported fields
}

func NewGoogleOAuth2Authorizer

func NewGoogleOAuth2Authorizer(id string) *GoogleOAuth2Authorizer

func (*GoogleOAuth2Authorizer) Authorize

func (g *GoogleOAuth2Authorizer) Authorize(token string, c Context) (string, error)

type Handler

type Handler func(w http.ResponseWriter, r *http.Request, c Context)

type Item

type Item struct {
    Blob   string
    Bucket string
    Tag    string
}

type Memstorage

type Memstorage map[string]Bucket

func (Memstorage) Delete

func (m Memstorage) Delete(bucket, tmp string) error

func (Memstorage) Download

func (m Memstorage) Download(bucket, id string, w io.Writer, c Context) (int64, error)

func (Memstorage) Move

func (m Memstorage) Move(srcBucket, src, dstBucket, dst string, c Context) error

func (Memstorage) Upload

func (m Memstorage) Upload(bucket, tmp string, r io.Reader, c Context, errs chan error, done chan struct{})

type Memstore

type Memstore map[string]*Collection

func (Memstore) AddItemToCollection

func (m Memstore) AddItemToCollection(slug string, item Item) error

func (Memstore) CreateCollection

func (m Memstore) CreateCollection(slug, name string) (Collection, error)

func (Memstore) GetCollectionData

func (m Memstore) GetCollectionData(slug string) (Collection, error)

func (Memstore) GetCollectionItems

func (m Memstore) GetCollectionItems(slug string) (map[string]Item, error)

func (Memstore) GetItemFromCollection

func (m Memstore) GetItemFromCollection(slug, tag string) (Item, error)

func (Memstore) Init

func (m Memstore) Init(dbName string) error

func (Memstore) UpdateCollection

func (m Memstore) UpdateCollection(slug, name string) error

type SQLStore

type SQLStore sql.DB

func (*SQLStore) AddItemToCollection

func (s *SQLStore) AddItemToCollection(slug string, item Item) error

func (*SQLStore) CreateCollection

func (s *SQLStore) CreateCollection(slug, name string) (Collection, error)

func (*SQLStore) GetCollectionData

func (s *SQLStore) GetCollectionData(slug string) (Collection, error)

func (*SQLStore) GetCollectionItems

func (s *SQLStore) GetCollectionItems(slug string) (map[string]Item, error)

func (*SQLStore) GetItemFromCollection

func (s *SQLStore) GetItemFromCollection(slug, tag string) (Item, error)

func (*SQLStore) Init

func (s *SQLStore) Init(name string) error

func (*SQLStore) UpdateCollection

func (s *SQLStore) UpdateCollection(slug, name string) error

type Storage

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

func NewGCSStorage(gcsClientEmail, gcsTokenURI string, gcsPemBytes []byte) (Storage, error)

func NewMemStorage

func NewMemStorage() Storage

type Usage

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

type UsageTracker struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewUsageTracker

func NewUsageTracker() *UsageTracker

func (*UsageTracker) TrackDownloads

func (u *UsageTracker) TrackDownloads(id string) (bytes, requests chan int64)

func (*UsageTracker) TrackUploads

func (u *UsageTracker) TrackUploads(id string) (bytes, requests chan int64)

Generated by godoc2md

gifs-api's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.