Skip to content

Commit 0dd353e

Browse files
committed
Updates for REST server handling, add base-url config parameter
1 parent 4defe52 commit 0dd353e

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

convex-cli/src/main/java/convex/cli/peer/PeerStart.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public class PeerStart extends APeerCommand {
6363
description = "URL for the peer to set for other peers to use.")
6464
private String url;
6565

66+
@Option(names = { "--base-url" },
67+
description = "Base URL for REST API / web access.")
68+
private String baseURL;
69+
70+
6671
@Option(names = { "--norest" }, description = "Disable REST srever.")
6772
private boolean norest;
6873

@@ -161,6 +166,7 @@ public void execute() throws InterruptedException {
161166
config.put(Keywords.KEYPAIR, peerKey);
162167
config.put(Keywords.STORE, store);
163168
config.put(Keywords.URL, url);
169+
config.put(Keywords.BASE_URL, baseURL);
164170
if (genesisKey!=null) {
165171
AccountKey gpk=genesisKey.getAccountKey();
166172
State state=Init.createState(gpk,gpk,List.of(gpk));

convex-core/src/main/java/convex/core/cvm/Keywords.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public class Keywords {
6161

6262
public static final Keyword BIND_ADDRESS = Keyword.intern("bind-address");
6363
public static final Keyword URL = Keyword.intern("url");
64-
64+
public static final Keyword BASE_URL = Keyword.intern("base-url");
65+
6566
// Account record keys
6667
public static final Keyword SEQUENCE = Keyword.intern("sequence");
6768
public static final Keyword KEY = Keyword.intern("key");
@@ -149,4 +150,5 @@ public class Keywords {
149150

150151

151152

153+
152154
}

convex-peer/src/main/java/convex/net/impl/netty/NettyInboundHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public NettyInboundHandler(Consumer<Message> receiveAction, Predicate<Message> r
3434
@Override
3535
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { // (4)
3636
// Close the connection when an exception is raised.
37-
log.info("Closed Netty channel due to: "+cause.getMessage(),cause);
37+
log.debug("Closed Netty channel due to: "+cause.getMessage(),cause);
3838
ctx.close();
3939
}
4040

convex-restapi/src/main/java/convex/restapi/RESTServer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,17 @@ public HashMap<Keyword, Object> getConfig() {
287287
return server.getConfig();
288288
}
289289

290+
/**
291+
* Gets the base URL to use for external links. May be null
292+
* @return
293+
*/
294+
public String getBaseURL() {
295+
Object o= server.getConfig().get(Keywords.BASE_URL);
296+
if (o instanceof String) return (String)o;
297+
return null;
298+
}
299+
300+
290301
public static void main(String[] args) throws InterruptedException, ConfigException, LaunchException {
291302
HashMap<Keyword,Object> config=new HashMap<>();
292303
config.put(Keywords.KEYPAIR, AKeyPair.generate());

0 commit comments

Comments
 (0)