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