api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 6 Imported by: 0

README

Ulysses API Specs

Public RESTful API

Documentation

Index

Constants

View Source
const (
	HTTP_METHOD_GET uint = iota
	HTTP_METHOD_POST
)

Variables

View Source
var (
	ErrNotAllowDirectFuncReg error = errors.New("api.RegisterApiEndpoint(): no direct handler func registration is allowed")
	ErrBadMethod             error = errors.New("api.RegisterApiEndpoint(): bad method")
	ErrRepeatGetPath         error = errors.New("api.RegisterApiEndpoint(): repeated path for GET method")
	ErrRepeatPostPath        error = errors.New("api.RegisterApiEndpoint(): repeated path for POST method")
)

Functions

func ExportHandlerMaps

func ExportHandlerMaps() (getMap map[string]*gin.HandlerFunc, postMap map[string]*gin.HandlerFunc)

func ImportToGinEngine

func ImportToGinEngine(router *gin.Engine, urlPath string)

func RegisterApiEndpoint

func RegisterApiEndpoint(method uint, relativePath string, handler *gin.HandlerFunc) error

RegisterNewAPIEndpoint() allows only one single handler function, unlike with direct Gin.Router access. note: this is overpowered and makes the system vulnerable to malicious code. in this version, I made it callable ONLY from main package.

func RegisterApiEndpointJSON

func RegisterApiEndpointJSON(method uint, relativePath string, handler HandlerFuncJSON) error

This function should wrap the JSON and StatCode returned from handler, register it

Types

type HandlerFuncJSON

type HandlerFuncJSON func(*LessContext) (status int, json gin.H)

type LessContext

type LessContext struct {
	Request *http.Request
}

TODO: Add more safe-to-expose access

Jump to

Keyboard shortcuts

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