Simple REST Host
Last updated
Last updated
Assemble and publish a REST web service endpoint by implementing its web methods through events using SimpleRESTHost.
The Base URL of the web service must be configured to be hosted on the server that it is deployed to.
To achieve this in Linx, use the +
wildcard character instead of your hostname in the Base URL property.
https://+:{port}/{path}
When the service is deployed it will use the current server.
The security scheme to use.
API Key and HTTP Bearer are supported.
When hosting a web service you need to indicate what the security requirements are for granting clients access to your web service.
When selecting the API Key security scheme it means that:
a) a client that consumes your web service must provide a key value that is associated with your API, and
b) your application must authenticate the key value that is received from the client.
Your web service application will receive the API key via a request header, named 'Authorization', that Linx makes available at =$.Input.Data.AuthenticationData.ApiKey.ProvidedToken
.
Authentication of the received key is performed in the SimpleRESTHost service's OperationEvents_Authenticate event handler.
Do the following:
Set a String variable to $.Input.Data.AuthenticationData.ApiKey.ProvidedToken
.
If the required key is stored in a database, check if the provided key matches the key in the database.
If there is a match, set $.Output.Data.HttpContext.User.IsAuthenticated
to 'true'.
Only available when 'HTTP Bearer' is selected for the Security property.
The HTTP bearer secret key, for issuing and authenticating security tokens.
Define your web API operations. Click on the Operations Editor icon [...] to add your operations.
Operations properties
The following properties are available in the Operations Editor:
Name: Enter a descriptive name for the operation.
Path: The path for where the operation can be accessed, in the format /path/{parameters}
.
Header parameters: Specify the headers that are expected from requests. Click on the ...
icon to add Header Parameters.
Query string parameters: Specify the Query string parameters that are expected from requests. Click on the ...
icon to add Query String Parameters.
Request body: The supported data types for the request. Select from the drop-down list.
Response body: The supported data types for the response. Select from the drop-down list.
Click the ADD OPERATION button to add more operations.
Hide or show details for internal server errors in HTTP responses. Note that this is a security consideration for production systems.
Options:
true
false
The maximum allowed size of any request body, in megabytes.
Default: 30
Select to generate documentation for your API.
Options:
Redocly
Swagger UI
To access your generated documentation, append /swagger
or /redocly
to your Base URI, depending on the documentation type.
A list of allowed origin URLs for cross-origin resource sharing.
Click the editor icon to add relevant URLs.
Select to show the Authenticate event handler. This handler will execute for every authentication scheme associated with an operation, before the execution of the operation.
Select to show the Before-Operation event handler. This handler will execute before the execution of any operation.
Select to show the After-Operation event handler. This handler will execute after the execution of any operation.
Apply security scheme: The security scheme is associated with your selection in the property. For each operation you can decide if the selected security scheme should be applied to the specific operation or not. Select 'Yes' to apply the security scheme to your operation.
The maximum number of concurrent connections to accept (per client). Use -1
for infinite, or null to use the machine wide setting from the registry. The default value is null. For more details on how to find out what the registry default is, go .
For more on API documentation go .