Add guarantees that PRESTO server constructors do not raise exceptions. (#66)
This commit is contained in:
parent
a638b7a05b
commit
5ca16485e4
|
@ -13,6 +13,8 @@ import stew/results
|
||||||
import route, common, segpath, servercommon, serverprivate, agent
|
import route, common, segpath, servercommon, serverprivate, agent
|
||||||
export options, chronos, shttpserver, servercommon, chronicles, agent
|
export options, chronos, shttpserver, servercommon, chronicles, agent
|
||||||
|
|
||||||
|
{.push raises: [].}
|
||||||
|
|
||||||
type
|
type
|
||||||
SecureRestServer* = object of RootObj
|
SecureRestServer* = object of RootObj
|
||||||
server*: SecureHttpServerRef
|
server*: SecureHttpServerRef
|
||||||
|
@ -68,11 +70,11 @@ proc new*(t: typedesc[SecureRestServerRef],
|
||||||
else:
|
else:
|
||||||
{.fatal: "Error type is not supported".}
|
{.fatal: "Error type is not supported".}
|
||||||
|
|
||||||
proc localAddress*(rs: SecureRestServerRef): TransportAddress {.raises: [].} =
|
proc localAddress*(rs: SecureRestServerRef): TransportAddress =
|
||||||
## Returns `rs` bound local socket address.
|
## Returns `rs` bound local socket address.
|
||||||
rs.server.instance.localAddress()
|
rs.server.instance.localAddress()
|
||||||
|
|
||||||
proc state*(rs: SecureRestServerRef): RestServerState {.raises: [].} =
|
proc state*(rs: SecureRestServerRef): RestServerState =
|
||||||
## Returns current REST server's state.
|
## Returns current REST server's state.
|
||||||
case rs.server.state
|
case rs.server.state
|
||||||
of HttpServerState.ServerClosed:
|
of HttpServerState.ServerClosed:
|
||||||
|
|
|
@ -13,6 +13,8 @@ import stew/results
|
||||||
import route, common, segpath, servercommon, serverprivate, agent
|
import route, common, segpath, servercommon, serverprivate, agent
|
||||||
export options, chronos, httpserver, servercommon, chronicles, agent
|
export options, chronos, httpserver, servercommon, chronicles, agent
|
||||||
|
|
||||||
|
{.push raises: [].}
|
||||||
|
|
||||||
type
|
type
|
||||||
RestServer* = object of RootObj
|
RestServer* = object of RootObj
|
||||||
server*: HttpServerRef
|
server*: HttpServerRef
|
||||||
|
@ -61,11 +63,11 @@ proc new*(t: typedesc[RestServerRef],
|
||||||
else:
|
else:
|
||||||
{.fatal: "Error type is not supported".}
|
{.fatal: "Error type is not supported".}
|
||||||
|
|
||||||
proc localAddress*(rs: RestServerRef): TransportAddress {.raises: [].} =
|
proc localAddress*(rs: RestServerRef): TransportAddress =
|
||||||
## Returns `rs` bound local socket address.
|
## Returns `rs` bound local socket address.
|
||||||
rs.server.instance.localAddress()
|
rs.server.instance.localAddress()
|
||||||
|
|
||||||
proc state*(rs: RestServerRef): RestServerState {.raises: [].} =
|
proc state*(rs: RestServerRef): RestServerState =
|
||||||
## Returns current REST server's state.
|
## Returns current REST server's state.
|
||||||
case rs.server.state
|
case rs.server.state
|
||||||
of HttpServerState.ServerClosed:
|
of HttpServerState.ServerClosed:
|
||||||
|
|
Loading…
Reference in New Issue