-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from walt-id/feat-configurable-bind-address
Feat configurable bind address
- Loading branch information
Showing
3 changed files
with
39 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
package id.walt.cli | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.parameters.options.default | ||
import com.github.ajalt.clikt.parameters.options.multiple | ||
import com.github.ajalt.clikt.parameters.options.option | ||
import com.github.ajalt.clikt.parameters.types.int | ||
import id.walt.signatory.SignatoryRestAPI | ||
import id.walt.rest.RestAPI | ||
|
||
class ServeCommand : CliktCommand( | ||
name = "serve", | ||
help = """Run the walt.id SSI KIT as RESTful service. | ||
Runs the library as RESTful service and exposes following APIs: | ||
Runs the library as RESTful service and exposes following APIs on the specified bind address (default: ${RestAPI.BIND_ADDRESS}): | ||
- walt.id Core API at ${RestAPI.API_HOST}:${RestAPI.CORE_API_PORT} | ||
- walt.id Core API at the specified API port (default: ${RestAPI.CORE_API_PORT}) | ||
- walt.id ESSIF API at ${RestAPI.API_HOST}:${RestAPI.ESSIF_API_PORT} | ||
- walt.id ESSIF API at the specified ESSIF API port (default: ${RestAPI.ESSIF_API_PORT}) | ||
- walt.id Signatory API at ${RestAPI.API_HOST}:${SignatoryRestAPI.SIGNATORY_API_PORT}""" | ||
- walt.id Signatory API at the specified Signatory API port (default: ${SignatoryRestAPI.SIGNATORY_API_PORT}) | ||
Additional API target servers can be specified using the -s option. | ||
""" | ||
) { | ||
val apiPort: Int by option(help = "Core API port [${RestAPI.CORE_API_PORT}]", names = *arrayOf("-p", "--port")).int().default(RestAPI.CORE_API_PORT) | ||
val essifPort: Int by option(help = "Essif API port [${RestAPI.ESSIF_API_PORT}]", names = *arrayOf("-e", "--essif-port")).int().default(RestAPI.ESSIF_API_PORT) | ||
val signatoryPort: Int by option(help = "Signatory API port [${SignatoryRestAPI.SIGNATORY_API_PORT}]", names = *arrayOf("-s", "--signatory-port")).int().default(SignatoryRestAPI.SIGNATORY_API_PORT) | ||
val bindAddress: String by option(help = "Bind address for API service [127.0.0.1]", names = *arrayOf("-b", "--bind-address")).default("127.0.0.1") | ||
val apiTargetUrls: List<String> by option(help = "Additional API target urls for swagger UI, defaults to root context '/'", names = *arrayOf("-t", "--target-url")).multiple() | ||
|
||
override fun run() { | ||
RestAPI.start() | ||
SignatoryRestAPI.start() | ||
RestAPI.start(apiPort, essifPort, bindAddress, apiTargetUrls) | ||
SignatoryRestAPI.start(signatoryPort, bindAddress, apiTargetUrls) | ||
|
||
echo() | ||
echo(" walt.id Core API:${RestAPI.coreApiUrl}") | ||
echo(" walt.id ESSIF API: ${RestAPI.essifApiUrl}") | ||
echo(" walt.id Signatory API: ${SignatoryRestAPI.signatoryApiUrl}") | ||
echo(" walt.id Core API: http://${bindAddress}:${apiPort}") | ||
echo(" walt.id ESSIF API: http://${bindAddress}:${essifPort}") | ||
echo(" walt.id Signatory API: http://${bindAddress}:${signatoryPort}") | ||
echo() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters