Expand description
Web-related utilities
Example
use titanium::web;
use web::prelude::*;
#[titanium::main]
async fn main() -> web::Result<()> {
let mut app = web::new_server();
app.at("/")
.with(web::WebSocket::new(|_, mut stream| async move {
while let Some(Ok(web::Message::Text(input))) = stream.next().await {
println!("data: {}", &input);
stream
.send_string(input)
.await?;
}
Ok(())
}))
.get(web::root_page_endpoint);
web::serve_internals(&mut app);
web::serve_client_code(&mut app, include_str!("./client.js"));
app.listen("127.0.0.1:8080").await?;
Ok(())
}
Modules
- Imports the prelude from other libraries.
Structs
- endpoint/middleware handler for websockets in tide
Enums
- An enum representing the various forms of a WebSocket message.
Constants
- A basic HTML page that should be served when the root of the server is requested.
Functions
- Creates a new server instance.
- Serves a basic HTML page that should be served when the root of the server is requested.
- Serves a javascript file from a
&'static str
at the specified path. This is used to serve the client code. - Serves the internal javascript files that are required for the web server to function.
- Serves a javascript file from a
&'static str
at the specified path.
Type Definitions
- A specialized Result type for Tide.