Skip to content

Commit

Permalink
Minimal HTTP API
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernard Labno committed Jan 11, 2019
1 parent c2043b5 commit b20c734
Show file tree
Hide file tree
Showing 34 changed files with 1,112 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.git
.gitignore
.gitmodules
.dockerignore
.travis.yml
docker-compose.yml
docker-compose-base.yml
Dockerfile
.idea
*.iml
target
support
.gradle
build
out
doc

http-api/docker/dev/Dockerfile
http-api/docker/prod/Dockerfile
http-api/.dockerignore
http-api/.editorconfig
http-api/.git
http-api/.gitignore
http-api/.travis.yml
http-api/support
33 changes: 26 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
language: java
jdk: openjdk10
before_install:
grep -v '^#' assets/src/main/resources/META-INF/services/bisq.asset.Asset | sort --check --dictionary-order --ignore-case
sudo: required
services:
- docker
jobs:
include:
- stage: asset ordering
install: echo No installation needed
script: grep -v '^#' assets/src/main/resources/META-INF/services/bisq.asset.Asset | sort --check --dictionary-order --ignore-case
- stage: build
- stage: integration
env:
- CUBE_LOGGER_ENABLE=true
install: cd http-api; docker-compose build;
script: ../gradlew testIntegration;
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
notifications:
slack:
on_success: change
on_failure: always
rooms:
- secure: EzlqWTBuhb3FCfApjUXaShWgsWOVDwMXI7ISMiVBkcl2VFISYs/lc/7Qjr7rdy4iqQOQXMcUPHdwMUp0diX+GxiSjLARjUpKIvNOPswZWBL+3Z1h28jyOwtHRviZbM1EU0BZROrr+ODyTNz2lf+L1iXTkpSvk50o5JAnAkumsPw=
slack:
on_success: change
on_failure: always
rooms:
- secure: EzlqWTBuhb3FCfApjUXaShWgsWOVDwMXI7ISMiVBkcl2VFISYs/lc/7Qjr7rdy4iqQOQXMcUPHdwMUp0diX+GxiSjLARjUpKIvNOPswZWBL+3Z1h28jyOwtHRviZbM1EU0BZROrr+ODyTNz2lf+L1iXTkpSvk50o5JAnAkumsPw=
80 changes: 80 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,85 @@ configure(project(':core')) {
}


configure(project(':http-api')) {

apply plugin: 'application'

mainClassName = 'bisq.httpapi.app.HttpApiMain'

dependencies {
compile project(':common')
compile project(':assets')
compile project(':core')
compile project(':p2p')

compile 'org.eclipse.jetty:jetty-servlet:9.4.14.v20181114'
compile 'javax.activation:activation:1.1.1'
compile 'javax.ws.rs:javax.ws.rs-api:2.1'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.27'
compile 'org.glassfish.jersey.inject:jersey-hk2:2.27'
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.27'
compile 'org.glassfish.jersey.media:jersey-media-multipart:2.27'
compile 'org.glassfish.jersey.ext:jersey-bean-validation:2.27'

compile 'io.swagger.core.v3:swagger-jaxrs2:2.0.6'
compile 'org.webjars:swagger-ui:3.20.1'

compileOnly 'org.projectlombok:lombok:1.18.2'
annotationProcessor 'org.projectlombok:lombok:1.18.2'

testCompile 'junit:junit:4.12'
testCompile('org.mockito:mockito-core:2.8.9') {
exclude(module: 'objenesis')
}
testCompileOnly 'org.projectlombok:lombok:1.18.2'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.2'
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:2.7.5"
testCompile "com.github.javafaker:javafaker:0.14"
testCompile "org.arquillian.universe:arquillian-junit:1.2.0.1"
testCompile "org.arquillian.universe:arquillian-cube-docker:1.2.0.1"
testCompile "org.arquillian.cube:arquillian-cube-docker:1.15.3"
testCompile "io.rest-assured:rest-assured:3.0.2"
}

sourceSets {
testIntegration {
java.srcDir 'src/testIntegration/java'
resources.srcDir 'src/testIntegration/resources'
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
}

task testIntegration(type: Test) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = 'Runs the integration tests.'

maxHeapSize = '1024m'

testClassesDir = sourceSets.testIntegration.output.classesDir
classpath = sourceSets.testIntegration.runtimeClasspath

binResultsDir = file("$buildDir/http-api/integration-test-results/binary/testIntegration")

reports {
html.destination = "$buildDir/http-api/reports/integration-test"
junitXml.destination = "$buildDir/http-api/integration-test-results"
}

systemProperties = [
CUBE_LOGGER_ENABLE: System.getenv('CUBE_LOGGER_ENABLE')
]

testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'

mustRunAfter tasks.test
}
}


configure(project(':desktop')) {
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'witness'
Expand All @@ -291,6 +370,7 @@ configure(project(':desktop')) {
compile project(':p2p')
compile project(':core')
compile project(':common')
compile project(':http-api')
compile 'org.controlsfx:controlsfx:8.0.6_20'
compile 'org.reactfx:reactfx:2.0-M3'
compile 'net.glxn:qrgen:1.3'
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/app/AppOptionKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ public class AppOptionKeys {
public static final String IGNORE_DEV_MSG_KEY = "ignoreDevMsg";
public static final String USE_DEV_PRIVILEGE_KEYS = "useDevPrivilegeKeys";
public static final String REFERRAL_ID = "referralId";
public static final String HTTP_API_EXPERIMENTAL_FEATURES_ENABLED = "enableHttpApiExperimentalFeatures";
public static final String HTTP_API_HOST = "httpApiHost";
public static final String HTTP_API_PORT = "httpApiPort";
}
14 changes: 14 additions & 0 deletions core/src/main/java/bisq/core/app/BisqEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ public static boolean isDaoActivated(Environment environment) {

protected final boolean externalTorUseSafeCookieAuthentication, torStreamIsolation;

@Getter
protected final String httpApiHost;
@Getter
protected final Integer httpApiPort;
@Getter
protected boolean httpApiExperimentalFeaturesEnabled;

public BisqEnvironment(OptionSet options) {
this(new JOptCommandLinePropertySource(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME, checkNotNull(
options)));
Expand Down Expand Up @@ -249,6 +256,13 @@ public BisqEnvironment(PropertySource commandLineProperties) {
referralId = commandLineProperties.containsProperty(AppOptionKeys.REFERRAL_ID) ?
(String) commandLineProperties.getProperty(AppOptionKeys.REFERRAL_ID) :
"";
httpApiExperimentalFeaturesEnabled = commandLineProperties.containsProperty(AppOptionKeys.HTTP_API_EXPERIMENTAL_FEATURES_ENABLED);
httpApiHost = commandLineProperties.containsProperty(AppOptionKeys.HTTP_API_HOST) ?
(String) commandLineProperties.getProperty(AppOptionKeys.HTTP_API_HOST) :
"127.0.0.1";
httpApiPort = Integer.parseInt(commandLineProperties.containsProperty(AppOptionKeys.HTTP_API_PORT) ?
(String) commandLineProperties.getProperty(AppOptionKeys.HTTP_API_PORT) :
"8080");
useDevMode = commandLineProperties.containsProperty(CommonOptionKeys.USE_DEV_MODE) ?
(String) commandLineProperties.getProperty(CommonOptionKeys.USE_DEV_MODE) :
"";
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/bisq/core/app/BisqExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@ protected void customizeOptionParsing(OptionParser parser) {
"Optional Referral ID (e.g. for API users or pro market makers)")
.withRequiredArg();

parser.accepts(AppOptionKeys.HTTP_API_EXPERIMENTAL_FEATURES_ENABLED, "Enable experimental features of HTTP API (disabled by default)");
parser.accepts(AppOptionKeys.HTTP_API_HOST, "Optional HTTP API host")
.withRequiredArg()
.defaultsTo("127.0.0.1");
parser.accepts(AppOptionKeys.HTTP_API_PORT, "Optional HTTP API port")
.withRequiredArg()
.ofType(int.class)
.defaultsTo(8080);

parser.accepts(CommonOptionKeys.USE_DEV_MODE,
format("Enables dev mode which is used for convenience for developer testing (default: %s)", "false"))
.withRequiredArg()
Expand Down
13 changes: 7 additions & 6 deletions desktop/src/main/java/bisq/desktop/app/BisqAppMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

import lombok.extern.slf4j.Slf4j;



import bisq.httpapi.service.HttpApiServer;

@Slf4j
public class BisqAppMain extends BisqExecutable {
private BisqApp application;
Expand All @@ -44,8 +48,6 @@ public BisqAppMain() {
super("Bisq Desktop", "bisq-desktop", Version.VERSION);
}

/* @Nullable
private BisqHttpApiServer bisqHttpApiServer;*/
/* @Nullable
private BisqGrpcServer bisqGrpcServer;
*/
Expand All @@ -64,7 +66,6 @@ public void onSetupComplete() {
log.debug("onSetupComplete");
}


///////////////////////////////////////////////////////////////////////////////////////////
// First synchronous execution tasks
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -135,9 +136,9 @@ protected void startApplication() {
protected void onApplicationStarted() {
super.onApplicationStarted();

/* if (runWithHttpApi()) {
bisqHttpApiServer = new BisqHttpApiServer();
}*/
if (runWithHttpApi()) {
injector.getInstance(HttpApiServer.class).startServer();
}
/*
if (runWithGrpcApi()) {
bisqGrpcServer = new BisqGrpcServer();
Expand Down
Loading

0 comments on commit b20c734

Please sign in to comment.