api

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MIT Imports: 6 Imported by: 2

README

Ulysses API Specs

Public RESTful API

Documentation

Index

Constants

View Source
const (
	Assets uint8 = iota
	Internal
	Payment
	PaymentCallback
	Plugin
	Server
)

API categories. Any package (no matter official or third party) except for main package must choose a category to register the API endpoints.

Variables

View Source
var (
	ErrBadMethod error = errors.New("api: bad method")

	ErrInvalidCategory error = errors.New("api: invalid category is selected")

	ErrNotAllowDirectFuncReg error = errors.New("api: no direct handler func registration is allowed")

	ErrRepeatGetPath  error = errors.New("api: repeated path for GET method")
	ErrRepeatPostPath error = errors.New("api: repeated path for POST method")

	ErrUnknownUserGroup error = errors.New("api: usergroup has no known access control function")
)

Functions

func AuthedCGET added in v0.0.9

func AuthedCGET(category uint8, relativePath string, userGroup string, handler ...*gin.HandlerFunc) error

func AuthedCPOST added in v0.0.9

func AuthedCPOST(category uint8, relativePath string, userGroup string, handler ...*gin.HandlerFunc) error

func AuthedGET added in v0.0.9

func AuthedGET(relativePath string, userGroup string, handler ...*gin.HandlerFunc) error

func AuthedPOST added in v0.0.9

func AuthedPOST(relativePath string, userGroup string, handler ...*gin.HandlerFunc) error

func CGET added in v0.0.6

func CGET(category uint8, relativePath string, handler ...*gin.HandlerFunc) error

CGET() stands for Categorized GET CGET(Payment, "dummy/test", f) will register f() as example.com/api/payment/dummy/test for GET method

func CPOST added in v0.0.6

func CPOST(category uint8, relativePath string, handler ...*gin.HandlerFunc) error

CPOST() stands for Categorized POST CPOST(Payment, "dummy/test", f) will register f() as example.com/api/payment/dummy/test for POST method

func FinalizeGinEngine added in v0.0.3

func FinalizeGinEngine(router *gin.Engine, pathPrefix string)

FinalizeGinEngine() binds all registered handlers to a gin.Engine. - pathPrefix should be in the format of aaa[/bbb[/ccc[/ddd]]] where [] encloses an optional portion

func GET added in v0.0.6

func GET(relativePath string, handler ...*gin.HandlerFunc) error

GET() is effectively like gin.Engine.GET() security measure: only main package can call GET(). For modules, refer to CGET() Warning: this function by-default registers routes which have no AUTHORIZATION. Use AuthedGET() instead!

func MessageResponse added in v0.0.9

func MessageResponse(status ResponseStatus, message string) gin.H

MessageResponse() creates a simple response with only status and message properties and registers the message to a map. Frontend may request the map at anytime for application localization/user-friendlization purposes. Recommended for: Create/Update/Delete actions

func POST added in v0.0.6

func POST(relativePath string, handler ...*gin.HandlerFunc) error

POST() is effectively like gin.Engine.POST(), but takes 1 handler function only security measure: only main package can call POST(). For modules, refer to CPOST() Warning: this function by-default registers routes which have no AUTHORIZATION. Use AuthedPOST() instead!

func PayloadResponse added in v0.0.9

func PayloadResponse(status ResponseStatus, payload interface{}) gin.H

PayloadResponse() creates a response with status and payload properties. Where payload could be a random typed interface. Recommended for: Read actions

func RegisterAccessControlFunc added in v0.0.9

func RegisterAccessControlFunc(userGroup string, acFuncs ...*gin.HandlerFunc)

func SampleAccessControlFunc added in v0.0.9

func SampleAccessControlFunc(c *gin.Context)

Types

type ResponseStatus added in v0.0.9

type ResponseStatus uint8
const (
	CANCELED ResponseStatus = iota
	ERROR
	SUCCESS
)

Jump to

Keyboard shortcuts

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