rest : REST and HTTP functions |
Top Previous Next |
The REST and HTTP functions provides a framework for building and using REST APIs as well as for performing generic HTTP requests and running a simple HTTP server. The REST and HTTP functions are only available in NX32L compilation mode.
The API uses three different types of SYSHANDLE: Server, Request and Response. Depending on what the needed functionality is, a different set of functions will be needed:
Requesting data from remote server: A request is created using restReqCreate and the contents of it are set using the different Request functions. The function restClientRequest then sends the request to a server and receives the response. The response must then be read using the Response functions.
Making data available to clients: The server is created using restServerCreate and endpoints are added using restServerEndpointAdd. The server is started using restServerStart and will now listen for incoming requests on the configured port. When it receives a request, the callback for the endpoint will be called and the necessary data must be read from the request using the Request functions. The response must be filled out using the Response functions and it will be sent back to the client.
The following REST and HTTP functions are available:
Server functions: The server functions are used to manage the REST/HTTP server.
Request functions: The request functions are used to create a request or to extract data from an incoming request.
Request Client certificate functions: The client certificate functions are used to set and examine the client certificate used to authenticate a client with a server.
Response functions: The response functions are used to extract data from a response to a request or to build the response to send for a request.
Client functions:
|