Endpoint Plugin

Bring your own custom endpoint to pREST

With prestd's http plugin system it is possible to create new endpoints in the "private" URI,

The plugin endpoint has the following default: /_PLUGIN/{file}/{func}

Naming patterns

The plugin endpoint (/_PLUGIN/{file}/{func}) receives two parameters:

  • File name: The name of the file without the extension ({file})

  • Function name: The name of the function ({func})

File name

The file name will be used on the endpoint to identify which library will be loaded when it receives the first access.

After the first access the library will not be loaded again, it will only be executed, i.e., if the file (.so) is changed after the first execution it will have no effect because it has already been loaded.

Function name

When talking about a compiled library we have no way of identifying its functions. Given this characteristic we have defined some name and behavior patterns to develop libraries for prestd.

function name: {HTTP Method}{Function Name}Handler

  • {HTTP Method}: The HTTP method that the function will be called for (in upper case letters)

  • {Function Name}: The name of the function that will be called

  • Handler: The suffix of the function name - it is always Handler

fmt.Sprintf("%s%sHandler", r.Method, funcName)

Example

  • Source code name: ./lib/src/hello.go

  • Library file name: ./lib/hello.so

  • Function name: GETHelloHandler

  • Endpoint: /_PLUGIN/hello/Hello

  • Verb HTTP: GET

Request:

Response:

Was this helpful?