pub enum HttpServerAction {
Bind {
path: String,
authenticated: bool,
local_only: bool,
cache: bool,
},
SecureBind {
path: String,
cache: bool,
},
Unbind {
path: String,
},
WebSocketBind {
path: String,
authenticated: bool,
extension: bool,
},
WebSocketSecureBind {
path: String,
extension: bool,
},
WebSocketUnbind {
path: String,
},
WebSocketPush {
channel_id: u32,
message_type: WsMessageType,
},
WebSocketExtPushOutgoing {
channel_id: u32,
message_type: WsMessageType,
desired_reply_type: MessageType,
},
WebSocketExtPushData {
id: u64,
hyperware_message_type: MessageType,
blob: Vec<u8>,
},
WebSocketClose(u32),
}
Expand description
crate::Request
type sent to http-server:distro:sys
in order to configure it.
If a crate::Response
is expected, all actions will return a crate::Response
with the shape Result<(), HttpServerActionError>
serialized to JSON.
Variants§
Bind
Bind expects a crate::LazyLoadBlob
if and only if cache
is TRUE.
The crate::LazyLoadBlob
should be the static file to serve at this path.
Fields
authenticated: bool
Set whether the HTTP request needs a valid login cookie, AKA, whether the user needs to be logged in to access this path.
local_only: bool
Set whether crate::Request
s can be fielded from anywhere, or only the loopback address.
cache: bool
Set whether to bind the crate::LazyLoadBlob
statically to this path. That is, take the
crate::LazyLoadBlob
bytes and serve them as the response to any request to this path.
SecureBind
SecureBind expects a crate::LazyLoadBlob
if and only if cache
is TRUE. The crate::LazyLoadBlob
should
be the static file to serve at this path.
SecureBind is the same as Bind, except that it forces requests to be made from the unique subdomain of the process that bound the path. These requests are always authenticated, and never local_only. The purpose of SecureBind is to serve elements of an app frontend or API in an exclusive manner, such that other apps installed on this node cannot access them. Since the subdomain is unique, it will require the user to be logged in separately to the general domain authentication.
Fields
cache: bool
Set whether to bind the crate::LazyLoadBlob
statically to this path. That is, take the
crate::LazyLoadBlob
bytes and serve them as the response to any request to this path.
Unbind
Unbind a previously-bound HTTP path
WebSocketBind
Bind a path to receive incoming WebSocket connections. Doesn’t need a cache since does not serve assets.
WebSocketSecureBind
SecureBind is the same as Bind, except that it forces new connections to be made from the unique subdomain of the process that bound the path. These are always authenticated. Since the subdomain is unique, it will require the user to be logged in separately to the general domain authentication.
WebSocketUnbind
Unbind a previously-bound WebSocket path
WebSocketPush
When sent, expects a crate::LazyLoadBlob
containing the WebSocket message bytes to send.
WebSocketExtPushOutgoing
When sent, expects a crate::LazyLoadBlob
containing the WebSocket message bytes to send.
Modifies the crate::LazyLoadBlob
by placing into HttpServerAction::WebSocketExtPushData
with id taken from this [
KernelMessage]
and hyperware_message_type
set to desired_reply_type
.
WebSocketExtPushData
For communicating with the ext.
Hyperware’s http-server sends this to the ext after receiving HttpServerAction::WebSocketExtPushOutgoing
.
Upon receiving reply with this type from ext, http-server parses, setting:
- id as given,
- message type as given (
crate::Request
orcrate::Response
), - body as
HttpServerRequest::WebSocketPush
, crate::LazyLoadBlob
as given.
WebSocketClose(u32)
Sending will close a socket the process controls.
Trait Implementations§
Source§impl Clone for HttpServerAction
impl Clone for HttpServerAction
Source§fn clone(&self) -> HttpServerAction
fn clone(&self) -> HttpServerAction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for HttpServerAction
impl Debug for HttpServerAction
Source§impl<'de> Deserialize<'de> for HttpServerAction
impl<'de> Deserialize<'de> for HttpServerAction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for HttpServerAction
impl RefUnwindSafe for HttpServerAction
impl Send for HttpServerAction
impl Sync for HttpServerAction
impl Unpin for HttpServerAction
impl UnwindSafe for HttpServerAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more