Documentation ¶
Overview ¶
Package api contains general REST API definitions.
The REST API provides an interface to EliasDB. It allows querying and modifying of the datastore. The API responds to GET, POST, PUT and DELETE requests in JSON if the request was successful (Return code 200 OK) and plain text in all other cases.
Common API definitions ¶
/about
Endpoint which returns an object with version information.
api_versions : List of available API versions e.g. [ "v1" ] product : Name of the API provider (EliasDB) version: : Version of the API provider revision: : Revision of the API provider
/swagger.json
Dynamically generated swagger definition file. See: http://swagger.io
Index ¶
- Constants
- Variables
- func RegisterRestEndpoints(endpointInsts map[string]RestEndpointInst)
- type DefaultEndpointHandler
- func (de *DefaultEndpointHandler) HandleDELETE(w http.ResponseWriter, r *http.Request, resources []string)
- func (de *DefaultEndpointHandler) HandleGET(w http.ResponseWriter, r *http.Request, resources []string)
- func (de *DefaultEndpointHandler) HandlePOST(w http.ResponseWriter, r *http.Request, resources []string)
- func (de *DefaultEndpointHandler) HandlePUT(w http.ResponseWriter, r *http.Request, resources []string)
- type RestEndpointHandler
- type RestEndpointInst
Constants ¶
const APIRoot = "/db"
APIRoot is the root directory for the REST API
const APIVersion = "1.0.0"
APIVersion is the version of the REST API
const EndpointAbout = APIRoot + "/about/"
EndpointAbout is the about endpoint URL (rooted). Handles about/
const EndpointSwagger = APIRoot + "/swagger.json/"
EndpointSwagger is the swagger endpoint URL (rooted). Handles swagger.json/
Variables ¶
var APIHost = "localhost:9090"
APIHost is the host definition for the REST API
var APISchemes = []string{"https"}
APISchemes is a list of supported protocol schemes
var DD *cluster.DistributedStorage
DD is the DistributedStorage instance which should be used by the REST API. (Only available if clustering is enabled.)
var DDLog *datautil.RingBuffer
DDLog is a ringbuffer containing cluster related logs. (Only available if clustering is enabled.)
var GM *graph.Manager
GM is the GraphManager instance which should be used by the REST API.
var GS graphstorage.Storage
GS is the GraphStorage instance which should be used by the REST API.
var GeneralEndpointMap = map[string]RestEndpointInst{ EndpointAbout: AboutEndpointInst, EndpointSwagger: SwaggerEndpointInst, }
GeneralEndpointMap contains general endpoints which should always be available
var HandleFunc = http.HandleFunc
HandleFunc to use for registering handlers
Should be of type: func(pattern string, handler func(http.ResponseWriter, *http.Request))
var SI *ecal.ScriptingInterpreter
SI is the ScriptingInterpreter instance which is working with the api.GM GraphManager instance.
Functions ¶
func RegisterRestEndpoints ¶
func RegisterRestEndpoints(endpointInsts map[string]RestEndpointInst)
RegisterRestEndpoints registers all given REST endpoint handlers.
Types ¶
type DefaultEndpointHandler ¶
type DefaultEndpointHandler struct { }
DefaultEndpointHandler represents the default endpoint handler.
func (*DefaultEndpointHandler) HandleDELETE ¶
func (de *DefaultEndpointHandler) HandleDELETE(w http.ResponseWriter, r *http.Request, resources []string)
HandleDELETE is a method stub returning an error.
func (*DefaultEndpointHandler) HandleGET ¶
func (de *DefaultEndpointHandler) HandleGET(w http.ResponseWriter, r *http.Request, resources []string)
HandleGET is a method stub returning an error.
func (*DefaultEndpointHandler) HandlePOST ¶
func (de *DefaultEndpointHandler) HandlePOST(w http.ResponseWriter, r *http.Request, resources []string)
HandlePOST is a method stub returning an error.
func (*DefaultEndpointHandler) HandlePUT ¶
func (de *DefaultEndpointHandler) HandlePUT(w http.ResponseWriter, r *http.Request, resources []string)
HandlePUT is a method stub returning an error.
type RestEndpointHandler ¶
type RestEndpointHandler interface { /* HandleGET handles a GET request. */ HandleGET(w http.ResponseWriter, r *http.Request, resources []string) /* HandlePOST handles a POST request. */ HandlePOST(w http.ResponseWriter, r *http.Request, resources []string) /* HandlePUT handles a PUT request. */ HandlePUT(w http.ResponseWriter, r *http.Request, resources []string) /* HandleDELETE handles a DELETE request. */ HandleDELETE(w http.ResponseWriter, r *http.Request, resources []string) /* SwaggerDefs is used to describe the endpoint in swagger. */ SwaggerDefs(s map[string]interface{}) }
RestEndpointHandler models a REST endpoint handler.
func AboutEndpointInst ¶
func AboutEndpointInst() RestEndpointHandler
AboutEndpointInst creates a new endpoint handler.
func SwaggerEndpointInst ¶
func SwaggerEndpointInst() RestEndpointHandler
SwaggerEndpointInst creates a new endpoint handler.
type RestEndpointInst ¶
type RestEndpointInst func() RestEndpointHandler
RestEndpointInst models a factory function for REST endpoint handlers.