Skip to content

Commit 5ea0735

Browse files
Update the service API prefix [ECR-3042]: (#826)
Change it from "/api" to "/api/services" for consistency with Exonum Core. Also, change service names: - "cryptocurrency-demo-service" -> "cryptocurrency-demo" - "ejb-qa-service" -> "qa"
1 parent 5ee9ece commit 5ea0735

File tree

10 files changed

+21
-16
lines changed

10 files changed

+21
-16
lines changed

exonum-java-binding/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1818
The release is based on Exonum 0.11
1919

2020
### Added
21-
- `toOptional()` method to `EntryIndexProxy`. (#790)
21+
- `toOptional()` method to `EntryIndexProxy`. (#790)
22+
23+
### Changed
24+
- Service HTTP APIs provided with `Service#createPublicApiHandlers` are now mounted
25+
on `/api/services` instead of `/api` for consistency with Exonum Core.
2226

2327
## [0.5.0] - 2019-03-13
2428

exonum-java-binding/common/src/test/java/com/exonum/binding/common/serialization/json/StoredConfigurationGsonSerializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class StoredConfigurationGsonSerializerTest {
5858
+ "\"majority_count\": null,\n"
5959
+ "\"services\": {\n"
6060
+ " \"configuration\": null,\n"
61-
+ " \"cryptocurrency-demo-service\": null\n"
61+
+ " \"cryptocurrency-demo\": null\n"
6262
+ "}\n"
6363
+ "}";
6464

exonum-java-binding/core/rust/exonum-java/start_cryptocurrency_node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ echo "ARTIFACT_PATH=${ARTIFACT_PATH}"
4141

4242
# Prepare the services configuration file
4343
SERVICES_CONFIG_FILE="services.toml"
44-
SERVICE_NAME="cryptocurrency-demo-service"
44+
SERVICE_NAME="cryptocurrency-demo"
4545
echo "[user_services]" > ${SERVICES_CONFIG_FILE}
4646
echo "${SERVICE_NAME} = '${ARTIFACT_PATH}'" >> ${SERVICES_CONFIG_FILE}
4747

exonum-java-binding/core/rust/exonum-java/start_qa_node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ echo "ARTIFACT_PATH=${ARTIFACT_PATH}"
4040

4141
# Prepare the services configuration file
4242
SERVICES_CONFIG_FILE="services.toml"
43-
SERVICE_NAME="ejb-qa-service"
43+
SERVICE_NAME="qa"
4444
echo "[user_services]" > ${SERVICES_CONFIG_FILE}
4545
echo "${SERVICE_NAME} = '${ARTIFACT_PATH}'" >> ${SERVICES_CONFIG_FILE}
4646

exonum-java-binding/core/src/main/java/com/exonum/binding/service/Service.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ default List<HashCode> getStateHashes(Snapshot snapshot) {
102102
* equal to the service name.
103103
*
104104
* <p>Please note that the path prefix is stripped from the request path when it is forwarded to
105-
* the given router. For example, if your service name is «cryptocurrency»,
106-
* and you have two endpoints «/send-money» and «/balance», use these names when
107-
* defining handlers, and they will be available by paths «/cryptocurrency/send-money»
108-
* and «/cryptocurrency/balance»:
105+
* the given router. For example, if your service name is «timestamping»,
106+
* and you have an endpoint «/timestamp», use this name when defining the handler and it will be
107+
* available by path «/api/services/timestamping/timestamp»:
108+
*
109109
* <pre><code>
110110
* router.get("/balance").handler((rc) -> {
111-
* rc.response().end("$1’000’000");
111+
* rc.response().end("2019-04-01T10:15:30+02:00[Europe/Kiev]");
112112
* });
113113
* </code></pre>
114114
*

exonum-java-binding/core/src/main/java/com/exonum/binding/service/adapters/UserServiceAdapter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class UserServiceAdapter {
4747

4848
private static final Logger logger = LogManager.getLogger(UserServiceAdapter.class);
4949

50-
private static final String API_ROOT_PATH = "/api";
50+
private static final String API_ROOT_PATH = "/api/services";
5151

5252
private final Service service;
5353
private final Server server;
@@ -164,7 +164,8 @@ public String initialize(long forkHandle) {
164164

165165
public void mountPublicApiHandler(long nodeNativeHandle) {
166166
try {
167-
checkState(node == null, "There is a node already: are you calling this method twice?");
167+
checkState(node == null, "There is a node already (%s): are you calling this method twice?",
168+
node);
168169
node = new NodeProxy(nodeNativeHandle);
169170
Router router = server.createRouter();
170171
service.createPublicApiHandlers(node, router);

exonum-java-binding/core/src/test/java/com/exonum/binding/service/adapters/UserServiceAdapterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void mountPublicApiHandler() {
205205
.thenReturn(serviceName);
206206

207207
serviceAdapter.mountPublicApiHandler(0x0A);
208-
verify(server).mountSubRouter(eq("/api/service1"), eq(router));
208+
verify(server).mountSubRouter(eq("/api/services/service1"), eq(router));
209209
}
210210

211211
@Test

exonum-java-binding/cryptocurrency-demo/frontend/src/plugins/blockchain.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const PER_PAGE = 10
2727
const MAX_VALUE = 2147483647
2828

2929
function getWallet (publicKey) {
30-
return axios.get(`/api/cryptocurrency-demo-service/wallet/${publicKey}`)
30+
return axios.get(`/api/services/cryptocurrency-demo/wallet/${publicKey}`)
3131
.then(response => response.data)
3232
.then(data => {
3333
return {
@@ -112,7 +112,7 @@ module.exports = {
112112
},
113113

114114
getHistory (publicKey) {
115-
return axios.get(`/api/cryptocurrency-demo-service/wallet/${publicKey}/history`).then(r => r.data)
115+
return axios.get(`/api/services/cryptocurrency-demo/wallet/${publicKey}/history`).then(r => r.data)
116116
}
117117
}
118118
}

exonum-java-binding/cryptocurrency-demo/src/main/java/com/exonum/binding/cryptocurrency/CryptocurrencyService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
public interface CryptocurrencyService extends Service {
2525
short ID = 42;
26-
String NAME = "cryptocurrency-demo-service";
26+
String NAME = "cryptocurrency-demo";
2727

2828
Optional<Wallet> getWallet(PublicKey ownerKey);
2929

exonum-java-binding/qa-service/src/main/java/com/exonum/binding/qaservice/QaService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public interface QaService extends Service {
3737

3838
short ID = 127;
39-
String NAME = "ejb-qa-service";
39+
String NAME = "qa";
4040

4141
HashCode submitCreateCounter(String counterName);
4242

0 commit comments

Comments
 (0)