api

package
v0.0.0-...-e4ea65f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2019 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const WsBufferSize = 4096

Variables

View Source
var Mutexes sync.Map
View Source
var Secret = []byte(getApiSecret())
View Source
var WorkDir = getWorkDir()

Functions

func GetServerAddress

func GetServerAddress() string

TODO: Move those to a different file/package

func Index

func Index(ctx *fasthttp.RequestCtx)

func Json

func Json(object interface{}, ctx *fasthttp.RequestCtx)

Types

type AllocateUploadSlotRequest

type AllocateUploadSlotRequest struct {
	Token         string `json:"token"`
	MaxSize       int64  `json:"max_size"`
	FileName      string `json:"file_name"`
	ToDisposeDate int64  `json:"to_dispose_date"`
	UploadHook    string `json:"upload_hook"`
}

func (*AllocateUploadSlotRequest) IsValid

func (req *AllocateUploadSlotRequest) IsValid() bool

type GenericResponse

type GenericResponse struct {
	Ok      bool   `json:"ok"`
	Message string `json:"message,omitempty"`
}

type GetUploadSlotResponse

type GetUploadSlotResponse struct {
	UploadSlot `json:"upload_slot"`
}

type Info

type Info struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type UploadSlot

type UploadSlot struct {
	MaxSize       int64  `json:"max_size"`
	Token         string `gorm:"primary_key",json:"token"`
	FileName      string `json:"file_name"`
	ToDisposeDate int64  `json:"to_dispose_date"`
	UploadHook    string `json:"upload_hook"`
}

type WebApi

type WebApi struct {
	MotdMessage *websocket.PreparedMessage
	Cron        *cron.Cron
	// contains filtered or unexported fields
}

func New

func New(db *gorm.DB) *WebApi

func (*WebApi) AllocateUploadSlot

func (api *WebApi) AllocateUploadSlot(ctx *fasthttp.RequestCtx)

func (*WebApi) DisposeStaleUploadSlots

func (api *WebApi) DisposeStaleUploadSlots()

func (*WebApi) ReadUploadSlot

func (api *WebApi) ReadUploadSlot(ctx *fasthttp.RequestCtx)

func (*WebApi) Run

func (api *WebApi) Run()

func (*WebApi) Upload

func (api *WebApi) Upload(ctx *fasthttp.RequestCtx)

func (*WebApi) UploadSlotInfo

func (api *WebApi) UploadSlotInfo(ctx *fasthttp.RequestCtx)

type WebsocketMotd

type WebsocketMotd struct {
	Info Info   `json:"info"`
	Motd string `json:"motd"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL