HTTP Server
Overview
The HTTP server serves as the entry point for Diarkis. The application server connects to the HTTP server to obtain the endpoint for real-time connections and the encryption keys.
Additionally, it is possible to define custom endpoints.
Setting Up the HTTP Server
To expose built-in commands to the client, you can use the diarkisexec
package for setup.
You can expose built-in commands by specifying the module through
diarkisexec.SetupDiarkis()
. By specifyingConfigPath
for each module, you can customize the settings.You can expose custom commands using
diarkisexec.SetServerCommandHandler()
.You can set up a UDP server using
diarkisexec.SetupDiarkisHTTPServer()
. You can customize server settings using a JSON file as an argument.
⚠️ The above functions need to be executed before calling
diarkisexec.StartDiarkis()
.
For more details, refer to the diarkisexec API reference.
Mesh Configuration
For meshConfigPath
, specify the path to the JSON file. For details, refer to Mesh Configuration.
HTTP Server Configuration
Settings are specified in JSON.
Key | Default | |
---|---|---|
address | "127.0.0.1" | Address for binding the UDP server |
port | "7000" | Port for the UDP server to bind. The UDP server will automatically find an available port starting from this specified port. |
useFixedPort | false | If true, the HTTP server will bind only to the specified port |
timeout | 5 | HTTP response timeout (in seconds) |
enableEncryption | true | If set to false, packet encryption and decryption will be disabled. Other servers must also be set similarly. |
For more details, refer to the HTTP API reference.
Creating Custom HTTP Endpoints
Diarkis's HTTP server allows you to write custom endpoints.
Last updated