solution: configuration for Websocket proxy

This commit is contained in:
Igor Artamonov
2021-10-27 20:34:04 -04:00
parent dc3c7b1249
commit 133937822c
3 changed files with 21 additions and 0 deletions

View File

@@ -58,6 +58,9 @@ class ProxyConfigReader : YamlConfigReader(), ConfigReader<ProxyConfig> {
getValueAsBool(input, "enabled")?.let {
config.enabled = it
}
getValueAsBool(input, "websocket")?.let {
config.websocketEnabled = it
}
val currentRoutes = HashSet<String>()
getList<MappingNode>(input, "routes")?.let { routes ->
config.routes = routes.value.map { route ->

View File

@@ -30,6 +30,7 @@ class ProxyConfigReaderSpec extends Specification {
then:
act.enabled
act.websocketEnabled
act.port == 8080
act.host == '127.0.0.1'
act.routes.size() == 1
@@ -39,6 +40,17 @@ class ProxyConfigReaderSpec extends Specification {
}
}
def "Read proxy config with websocket disabled"() {
setup:
def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-no-ws.yaml")
when:
def act = reader.read(config)
then:
act.enabled
!act.websocketEnabled
}
def "Read proxy config with two elements"() {
setup:
def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-two.yaml")

View File

@@ -0,0 +1,6 @@
proxy:
port: 8080
websocket: false
routes:
- id: ethereum
blockchain: ethereum