pass config

This commit is contained in:
Dmitriy Ryajov 2022-04-19 19:15:28 -06:00
parent ec6f3b8058
commit 45fe5ee8ff
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 6 additions and 3 deletions

View File

@ -123,7 +123,7 @@ proc new*(T: type DaggerServer, config: DaggerConf): T =
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
daggerNode = DaggerNodeRef.new(switch, store, engine, erasure, discovery)
restServer = RestServerRef.new(
daggerNode.initRestApi(),
daggerNode.initRestApi(config),
initTAddress("127.0.0.1" , config.apiPort),
bufferSize = (1024 * 64),
maxRequestBodySize = int.high)

View File

@ -21,11 +21,13 @@ import pkg/chronos
import pkg/presto
import pkg/libp2p
import pkg/stew/base10
import pkg/confutils
import pkg/libp2p/routing_record
import ../node
import ../blocktype
import ../conf
proc validate(
pattern: string,
@ -83,7 +85,7 @@ proc decodeString(T: type bool, value: string): Result[T, cstring] =
proc encodeString(value: bool): Result[string, cstring] =
ok($value)
proc initRestApi*(node: DaggerNodeRef): RestRouter =
proc initRestApi*(node: DaggerNodeRef, conf: DaggerConf): RestRouter =
var router = RestRouter.init(validate)
router.api(
MethodGet,
@ -318,6 +320,7 @@ proc initRestApi*(node: DaggerNodeRef): RestRouter =
return RestApiResponse.response(
"Id: " & $node.switch.peerInfo.peerId &
"\nAddrs: \n" & addrs & "\n")
"\nAddrs: \n" & addrs &
"\nRoot Dir: " & $conf.dataDir)
return router