[−][src]Struct northstar::Builder
Implementations
impl<A: ToSocketAddrs> Builder<A>
[src]
pub fn set_tls_dir(self, dir: impl Into<PathBuf>) -> Self
[src]
Sets the directory that northstar should look for TLS certs and keys into
Northstar will look for files called cert.pem
and key.pem
in the provided
directory.
This does not need to be set if both set_cert()
and
set_key()
have been called.
If not set, the default is cert/
pub fn set_cert(self, cert_path: impl Into<PathBuf>) -> Self
[src]
Set the path to the TLS certificate northstar will use
This defaults to cert/cert.pem
.
This does not need to be called it set_tls_dir()
has been
called.
pub fn set_key(self, key_path: impl Into<PathBuf>) -> Self
[src]
Set the path to the ertificate key northstar will use
This defaults to cert/key.pem
.
This does not need to be called it set_tls_dir()
has been
called.
This should of course correspond to the key set in
set_cert()
pub fn set_timeout(self, timeout: Duration) -> Self
[src]
Set the timeout on incoming requests
Note that this timeout is applied twice, once for the delivery of the request, and once for sending the client's response. This means that for a 1 second timeout, the client will have 1 second to complete the TLS handshake and deliver a request header, then your API will have as much time as it needs to handle the request, before the client has another second to receive the response.
If you would like a timeout for your code itself, please use
tokio::time::Timeout
to implement it internally.
The default timeout is 1 second. As somewhat of a workaround for
shortcomings of the specification, this timeout, and any timeout set using this
method, is overridden in special cases, specifically for MIME types outside of
text/plain
and text/gemini
, to be 30 seconds. If you would like to change or
prevent this, please see
override_complex_body_timeout
.
pub fn override_complex_body_timeout(self, timeout: Option<Duration>) -> Self
[src]
Override the timeout for complex body types
Many clients choose to handle body types which cannot be displayed by prompting the user if they would like to download or open the request body. However, since this prompt occurs in the middle of receiving a request, often the connection times out before the end user is able to respond to the prompt.
As a workaround, it is possible to set an override on the request timeout in specific conditions:
- Only override the timeout for receiving the body of the request. This will not override the timeout on sending the request header, nor on receiving the response header.
- Only override the timeout for successful responses. The only bodies which have bodies are successful ones. In all other cases, there's no body to timeout for
- Only override the timeout for complex body types. Almost all clients are
able to display
text/plain
andtext/gemini
responses, and will not prompt the user for these response types. This means that there is no reason to expect a client to have a human-length response time for these MIME types. Because of this, responses of this type will not be overridden.
This method is used to override the timeout for responses meeting these specific
criteria. All other stages of the connection will use the timeout specified in
set_timeout()
.
If this is set to None
, then the client will have the default amount of time
to both receive the header and the body. If this is set to Some
, the client
will have the default amount of time to recieve the header, and an additional
alotment of time to recieve the body.
The default timeout for this is 30 seconds.
pub fn add_route<H>(self, path: &'static str, handler: H) -> Self where
H: Fn(Request) -> BoxFuture<'static, Result<Response>> + Send + Sync + 'static,
[src]
H: Fn(Request) -> BoxFuture<'static, Result<Response>> + Send + Sync + 'static,
Add a handler for a route
A route must be an absolute path, for example "/endpoint" or "/", but not "endpoint". Entering a relative or malformed path will result in a panic.
For more information about routing mechanics, see the docs for RoutingNode
.
pub async fn serve(self) -> Result<()>
[src]
Auto Trait Implementations
impl<A> !RefUnwindSafe for Builder<A>
impl<A> Send for Builder<A> where
A: Send,
A: Send,
impl<A> Sync for Builder<A> where
A: Sync,
A: Sync,
impl<A> Unpin for Builder<A> where
A: Unpin,
A: Unpin,
impl<A> !UnwindSafe for Builder<A>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,