Documentation ¶
Index ¶
- Constants
- Variables
- func AuthErrHandler(ctx *fiber.Ctx, err error) error
- func AuthSetApikeys(keys []cfg.Apicontext)
- func AuthValidateAPIKey(c *fiber.Ctx, key string) (bool, error)
- func AuthValidateOnetimeKey(c *fiber.Ctx, key string, db *Db) (bool, error)
- func BackgroundCleaner(conf *cfg.Config, db *Db) chan bool
- func DeleteExpiredUploads(conf *cfg.Config, db *Db) error
- func FormCreate(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func FormDelete(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func FormDescribe(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func FormModify(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func FormPage(c *fiber.Ctx, cfg *cfg.Config, db *Db, shallexpire bool) error
- func FormsList(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func IsExpired(conf *cfg.Config, start time.Time, duration string) bool
- func JsonStatus(c *fiber.Ctx, code int, msg string) error
- func Log(format string, values ...any)
- func ProcessFormFiles(cfg *cfg.Config, members []string, id string) (string, string, error)
- func Runserver(conf *cfg.Config, args []string) error
- func SaveFormFiles(c *fiber.Ctx, cfg *cfg.Config, files []*multipart.FileHeader, id string) ([]string, error)
- func SendResponse(c *fiber.Ctx, msg string, err error) error
- func Sendmail(c *cfg.Config, recipient string, body string, subject string) error
- func SessionGetApicontext(c *fiber.Ctx) (string, error)
- func SessionGetFormId(c *fiber.Ctx) (string, error)
- func SetupAuthStore(conf *cfg.Config, db *Db) func(*fiber.Ctx) error
- func SetupServer(conf *cfg.Config) *fiber.App
- func Ts() string
- func UploadDelete(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func UploadDescribe(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func UploadFetch(c *fiber.Ctx, cfg *cfg.Config, db *Db, shallExpire ...bool) error
- func UploadModify(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func UploadPost(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func UploadsList(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func ZipDir(directory, zipfilename string) error
- type Db
- func (db *Db) Close()
- func (db *Db) Delete(apicontext string, id string) error
- func (db *Db) Get(apicontext string, id string, t int) (*common.Response, error)
- func (db *Db) Insert(id string, entry common.Dbentry) error
- func (db *Db) List(apicontext string, filter string, query string, t int) (*common.Response, error)
- func (db *Db) Lookup(apicontext string, id string, t int) (*common.Response, error)
- type Id
- type Meta
- type SetContext
Constants ¶
const ApiVersion string = "/v1"
const Bucket string = "data"
Variables ¶
var (
Apikeys []cfg.Apicontext
)
these vars can be savely global, since they don't change ever
var Sessionstore *session.Store
sessions are context specific and can be global savely
Functions ¶
func AuthErrHandler ¶
make sure we always return JSON encoded errors
func AuthValidateAPIKey ¶
validator hook, called by fiber via server keyauth.New()
func AuthValidateOnetimeKey ¶
validator hook, validates incoming api key against form id, which also acts as onetime api key
func FormDescribe ¶
returns just one form obj + error code
func FormPage ¶
Render the upload html form. Template given by --formpage, stored as text in cfg.Formpage. It will be rendered using golang's template engine, data to be filled in is the form matching the given id.
func IsExpired ¶
Calculate if time is up based on start time.Time and duration. Returns true if time is expired. Start time comes from the database.
aka:
if(now - start) >= duration { time is up}
func JsonStatus ¶
Wrapper to respond with proper json status, message and code, shall be prepared and called by the handlers directly.
func ProcessFormFiles ¶
generate return url. in case of multiple files, zip and remove them
func SaveFormFiles ¶
func SaveFormFiles(c *fiber.Ctx, cfg *cfg.Config, files []*multipart.FileHeader, id string) ([]string, error)
Extract form file[s] and store them on disk, returns a list of files
func SendResponse ¶
Used for non json-aware handlers, called by server
func Sendmail ¶
Send an email via an external mail gateway. SMTP Auth is required. Errors may occur with a time delay, like server timeouts etc. So only call it detached via go routine.
func SessionGetApicontext ¶
Retrieve the API Context name from the session, assuming is has been successfully authenticated. However, if there are no api contexts defined, we'll use 'default' (set in auth.validateAPIKey()).
If there's no apicontext in the session, assume unauth user, return ""
func SessionGetFormId ¶
Retrieve the formid (aka onetime api key) from the session. It is configured if an upload request has been successfully authenticated using a onetime key.
func SetupServer ¶
func UploadDelete ¶
delete file, id dir and db entry
func UploadDescribe ¶
returns just one upload obj + error code, no post processing by server
func UploadFetch ¶
func UploadsList ¶
returns the whole list + error code, no post processing by server
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
wrapper for bolt db
func (*Db) Get ¶
we only return one obj here, but could return more later FIXME: turn the id into a filter and call (Uploads|Forms)List(), same code!
type Meta ¶
type Meta struct {
Expire string `json:"expire" form:"expire"`
}
Binding from JSON, data coming from user, not tainted