handlers

package
v0.0.0-...-86fb063 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthMiddleware *jwt.GinJWTMiddleware

AuthMiddleware is JWT authorizer

View Source
var IdentityKey = "jwtid"

Functions

func AssertDirExists

func AssertDirExists(t *testing.T, p string)

func AssertFileExists

func AssertFileExists(t *testing.T, p string)

func CleanupOldTempFiles

func CleanupOldTempFiles()

CleanupOldTempFiles cleans up old temp files in temp upload folder

func GetUserFromJWT

func GetUserFromJWT(c *gin.Context) (string, error)

GetUserFromJWT validates the JWT and returns user model

func HandleLayersGet

func HandleLayersGet(c *gin.Context)

HandleLayersGet godoc @Summary Gets list of all layers @Security JWT @Produce json @Success 200 {string} success "" @Failure 500 {string} error "Internal error" @Router /layers [get]

func HandleObjectArchiveGet

func HandleObjectArchiveGet(c *gin.Context)

HandleObjectArchiveGet godoc @Summary HandleObjectArchiveGet gets an Object tar archive @Produce json @Param cid path string true "content identifier" @Success 200 {string} success "" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 500 {string} error "Internal error" @Router /object/archive/{cid} [get]

func HandleObjectArchiveUploadMultipart

func HandleObjectArchiveUploadMultipart(c *gin.Context)

HandleObjectArchiveUploadMultipart godoc @Summary HandleObjectArchiveUploadMultipart uploads a tar archive. It saves to IPFS, creates thumbs, then saves to S3 @Accept mpfd @Produce json @Param App-Key header string true "Application key header" @Success 200 object respObject success "CID of object" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 451 {string} error "Cannot expand tar" @Failure 500 {string} error "Internal error" @Router /object/archive/multipart [post]

func HandleObjectBatchUploadBegin

func HandleObjectBatchUploadBegin(c *gin.Context)

HandleObjectBatchUploadBegin godoc @Summary HandleObjectBatchUploadBegin starts a batch upload for an object @Accept json @Produce json @Success 200 object respBatchUploadBegin success "Batch upload session ID" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 500 {string} error "Internal error" @Router /object/batchUpload [post]

func HandleObjectBatchUploadEnd

func HandleObjectBatchUploadEnd(c *gin.Context)

HandleObjectBatchUploadEnd godoc @Summary HandleObjectBatchUploadEnd ends a batch upload and loads files to IPFS and S3 @Accept mpfd @Produce json @Success 200 object respObject success "CID of uploaded Object" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 451 {string} error "Cannot file session ID" @Failure 500 {string} error "Internal error" @Router /object/batchUpload/end/{sessionId} [put]

func HandleObjectBatchUploadMultipart

func HandleObjectBatchUploadMultipart(c *gin.Context)

HandleObjectBatchUploadMultipart @Summary HandleObjectBatchUploadMultipart Uploads multipart files to an Object. Optional path<n> form field specifies the full path for stored full path. @Accept json @Produce json @Success 200 {string} success "" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 451 {string} error "Cannot find sessionId" @Failure 500 {string} error "Internal error" @Router /object/batchUpload/multipart/{sessionId} [post]

func HandleObjectIndexGet

func HandleObjectIndexGet(c *gin.Context)

HandleObjectIndexGet godoc @Summary HandleObjectIndexGet gets an index at Object cid @Accept json @Produce json @Param cid path string true "object address" @Success 200 object respObject success "Object body" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 451 {string} error "Cannot find object" @Failure 500 {string} error "Internal error" @Router /object/{cid}/index [get]

func HandleObjectIndexPost

func HandleObjectIndexPost(c *gin.Context)

HandleObjectIndexPost godoc @Summary HandleObjectIndexPost adds an object index to IPFS and S3 @Accept json @Produce json @Param App-Key header string true "Application key header" @Param json body reqObject required "index only object to create as JSON" @Success 200 object respObject success "CID of object" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 451 {string} error "Cannot match arc selector with an arc" @Failure 452 {string} error "Cannot match pin selector with a pin" @Failure 500 {string} error "Internal error" @Router /object/index [post]

func HandleObjectSearch

func HandleObjectSearch(c *gin.Context)

HandleObjectSearch godoc @Summary HandleObjectSearch searches for Objects @Accept json @Produce json @Param json body reqObjectSearch required "search criteria JSON" @Success 200 object respObjectSearch success "Array of Objects matching search criteria" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 500 {string} error "Internal error" @Router /object/search [get]

func HandleTransactionEnqueue

func HandleTransactionEnqueue(c *gin.Context)

HandleTransactionEnqueue godoc @Summary HandleTransactionEnqueue enqueues a transaction for the transactor @Accept mpfd @Produce json @Param App-Key header string true "Application key header" @Param json body reqTransactionEnqueue required "transaction details" @Success 200 {string} success "" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 500 {string} error "Internal Server Error" @Router /transaction/enqueue [post]

func HandleTransactionQueueCallback

func HandleTransactionQueueCallback(c *gin.Context)

HandleTransactionQueueCallback godoc @Summary HandleTransactionQueueCallback handles queued callbacks from the transactor @Accept mpfd @Produce json @Param App-Key header string true "Application key header" @Success 200 object respObject success "CID of object" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 451 {string} error "Cannot find transaction matching UID" @Failure 500 {string} error "Internal Server Error" @Router /transaction/callback [post]

func HandleTransactionQueueGet

func HandleTransactionQueueGet(c *gin.Context)

HandleTransactionQueueGet godoc @Summary HandleTransactionQueueGet gets an item from the transaction queue from the transactor @Accept mpfd @Produce json @Param App-Key header string true "Application key header" @Success 200 object respTransaction success "transaction details" @Success 201 {string} success "no transactions" @Failure 400 {string} error "Request params wrong" @Failure 401 {string} error "Unauthorized" @Failure 500 {string} error "Internal Server Error" @Router /transaction/queue [get]

func PerformRequest

func PerformRequest(r http.Handler, method, relativePath, body string) *httptest.ResponseRecorder

func PerformRequestFull

func PerformRequestFull(r http.Handler, method, fullpath, body string) *httptest.ResponseRecorder

func SetupAuth

func SetupAuth(r *gin.Engine) *jwt.GinJWTMiddleware

SetupAuth Authenticates the user (logs in), sets up the JWT auth token, and returns username and rememberMeToken, requires the App-Key header to be present. There are two ways of logging in, supplying username/password or supplying RememberMeToken header. In both cases the user needs to activate the account first by clicking confirm email.

func SetupRouter

func SetupRouter() *gin.Engine

SetupRouter creates the Gin router

func UploadFile

func UploadFile(r http.Handler, method, p string, localPath string, remotePath string) (*httptest.ResponseRecorder, error)

func ValJWT

func ValJWT(c *gin.Context) string

ValJWT validates the JWT and returns user UID

Types

type ArcAndPin

type ArcAndPin struct {
	models.Arc
	models.Pin
}

type UserJWT

type UserJWT struct {
	Uid             string
	RememberMeToken string
}

User encoded into JWT

Jump to

Keyboard shortcuts

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