Enable overriding the API port number

Using an environment variable called BISQ_API_PORT, it is now possible
to override the default API port of 8080 to whichever available port
desired.

This enables running the API on a machine where port 8080 is occupied,
it also enables running multiple Bisq instances side-by-side with their
respective API's enabled.

Signed-off-by: Mike Rosseel <mike.rosseel@gmail.com>
This commit is contained in:
Mike Rosseel 2017-09-18 11:39:49 +02:00
parent a72986ff5b
commit 290d7237f4
No known key found for this signature in database
GPG key ID: 1D9920AF2A8E6BF0
3 changed files with 38 additions and 4 deletions

View file

@ -1,5 +1,12 @@
current api docs are at:
https://github.com/dan-da/bitsquare/blob/rpc_api/doc/api/README.md
# Bisq API
*Based on proposal XX*
## Enabling the api
--enableApi true
## Exploring the REST API
generated swagger docs are at:
http://localhost:8080/swagger
@ -7,5 +14,14 @@ http://localhost:8080/swagger
swagger.json can be found at (generate clients with swagger editor):
http://localhost:8080/swagger.json
the admin interface can be found at:
http://localhost:8080/admin[
## Overriding http port
Set an environment variable called "BISQ_API_PORT" to your desired port.
## TODO
Candidate for hosting the docs:
https://github.com/Rebilly/ReDoc
https://github.com/Rebilly/ReDoc

View file

@ -17,7 +17,9 @@ import io.bisq.core.user.Preferences;
import io.bisq.core.user.User;
import io.bisq.network.p2p.P2PService;
import io.dropwizard.Application;
import io.dropwizard.configuration.EnvironmentVariableSubstitutor;
import io.dropwizard.configuration.ResourceConfigurationSourceProvider;
import io.dropwizard.configuration.SubstitutingSourceProvider;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.federecio.dropwizard.swagger.SwaggerBundle;
@ -81,6 +83,13 @@ public class DropwizardApplication extends Application<ApiConfiguration> {
return configuration.swaggerBundleConfiguration;
}
});
// Overriding settings through environment variables, added to override the http port from 8080 to something else
// See http://www.dropwizard.io/1.1.4/docs/manual/core.html#configuration
bootstrap.setConfigurationSourceProvider(
new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
new EnvironmentVariableSubstitutor(false)
)
);
}
@Override

View file

@ -3,4 +3,13 @@ defaultName: Stranger
# the only required property is resourcePackage, for more config options see below
swagger:
resourcePackage: io.bisq.api.service
resourcePackage: io.bisq.api.service
server:
type: simple
applicationContextPath: /
adminContextPath: /admin
connector:
type: http
port: ${BISQ_API_PORT:-8080}