Documentation ¶
Index ¶
- Constants
- Variables
- func Version(w http.ResponseWriter, r *http.Request)
- type AsyncClient
- type AsyncClientConfig
- type BackupHandler
- type Client
- type ClientConfig
- type Database
- type DatabaseBackup
- type DownloadHandler
- type IndexView
- type LoginView
- type LogoutHandler
- type NavBarOpts
- type PartView
- type PasswordLoginHandler
- type ProjectsHandler
- type RBACMux
- type Server
- type ServerConfig
- type Upload
- type UploadHandler
- type UploadStatus
- type UploadType
- type Uploads
Constants ¶
const ClientUserAgent = "Virtual-VGO Client"
const CtxKeyVVGOIdentity = "vvgo_identity"
const LoginCookieDuration = 2 * 7 * 24 * 3600 * time.Second // 2 weeks
const MediaTypeUploadStatusesGob = "application/x.vvgo.pkg.api.upload_statuses.gob"
const MediaTypeUploadsGob = "application/x.vvgo.pkg.api.uploads.gob"
const UploadsTimeout = 5 * 60 * time.Second
Variables ¶
var ( ErrInvalidUploadType = errors.New("invalid upload type") ErrMissingProject = errors.New("missing project") ErrMissingPartNames = errors.New("missing part names") ErrEmptyFileBytes = errors.New("empty file bytes") )
var PublicFiles = "public"
Functions ¶
Types ¶
type AsyncClient ¶
type AsyncClient struct { *Client AsyncClientConfig // contains filtered or unexported fields }
func NewAsyncClient ¶
func NewAsyncClient(conf AsyncClientConfig) *AsyncClient
func (*AsyncClient) Close ¶
func (x *AsyncClient) Close()
func (*AsyncClient) Status ¶
func (x *AsyncClient) Status() <-chan UploadStatus
func (*AsyncClient) Upload ¶
func (x *AsyncClient) Upload(uploads ...Upload)
type AsyncClientConfig ¶
type AsyncClientConfig struct { MaxParallel int QueueLength int ClientConfig }
type BackupHandler ¶
func (BackupHandler) ServeHTTP ¶
func (x BackupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Client ¶
type Client struct {
ClientConfig
}
func NewClient ¶
func NewClient(config ClientConfig) *Client
func (*Client) Authenticate ¶
Authenticate queries the api server to check that the client has the uploader role. An error returns if the query fails or if the client does not have the uploader role.
func (*Client) GetProject ¶
GetProject queries the api server for the project data.
func (*Client) Upload ¶
func (x *Client) Upload(uploads ...Upload) []UploadStatus
type ClientConfig ¶
type Database ¶
Database acts as the wrapper/driver for any stateful data.
type DatabaseBackup ¶
type DatabaseBackup struct { // Timestamp when the backup document was created. Timestamp time.Time `json:"timestamp"` // Parts is the slice of _all_ parts in the database. Parts []parts.Part `json:"parts"` // ApiVersion is the version of the api server when this database backup was created. ApiVersion json.RawMessage `json:"api_version"` }
DatabaseBackup is a document containing a snapshot of the stateful data we want to backup.
type DownloadHandler ¶
type DownloadHandler map[string]func(ctx context.Context, objectName string) (url string, err error)
Accepts query params `object` and `bucket`. The map key is the bucket param. The map value function should return the url of the object and any error encountered.
func (DownloadHandler) ServeHTTP ¶
func (x DownloadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LogoutHandler ¶
LogoutHandler deletes the login session from the incoming request, if it exists.
func (LogoutHandler) ServeHTTP ¶
func (x LogoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type NavBarOpts ¶
type NavBarOpts struct {}
func NewNavBarOpts ¶
func NewNavBarOpts(ctx context.Context) NavBarOpts
type PasswordLoginHandler ¶
type PasswordLoginHandler struct { Sessions *login.Store // Logins is a map of login user and pass to a slice of roles for that login. Logins map[[2]string][]login.Role }
PasswordLoginHandler authenticates requests using form values user and pass and a static map of valid combinations. If the user pass combo exists in the map, then a login cookie with the mapped roles is create and sent in the response.
func (PasswordLoginHandler) ServeHTTP ¶
func (x PasswordLoginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ProjectsHandler ¶
type ProjectsHandler struct{}
func (ProjectsHandler) ServeHTTP ¶
func (x ProjectsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RBACMux ¶
type RBACMux struct { Basic map[[2]string][]login.Role Bearer map[string][]login.Role Sessions *login.Store *http.ServeMux }
Authenticate http requests using the sessions api If the request has a valid session or token with the required role, it is allowed access.
func (*RBACMux) HandleFunc ¶
func (auth *RBACMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request), role login.Role)
HandleFunc registers the handler function for the given pattern.
type ServerConfig ¶
type ServerConfig struct { ListenAddress string `split_words:"true" default:"0.0.0.0:8080"` MemberUser string `split_words:"true" default:"admin"` MemberPass string `split_words:"true" default:"admin"` UploaderToken string `split_words:"true" default:"admin"` DeveloperToken string `split_words:"true" default:"admin"` DistroBucketName string `split_words:"true" default:"vvgo-distro"` BackupsBucketName string `split_words:"true" default:"backups"` RedisNamespace string `split_words:"true" default:"local"` Login login.Config `envconfig:"login"` }
type Upload ¶
type UploadHandler ¶
type UploadHandler struct{ *Database }
func (UploadHandler) ServeHTTP ¶
func (x UploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*UploadHandler) ServeUploads ¶
func (x *UploadHandler) ServeUploads(ctx context.Context, uploads Uploads) []UploadStatus
type UploadStatus ¶
type UploadType ¶
type UploadType string
const ( UploadTypeClix UploadType = "clix" UploadTypeSheets UploadType = "sheets" )
func (UploadType) String ¶
func (x UploadType) String() string