Skip to content

Commit

Permalink
rust example
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Nov 7, 2024
1 parent 4db3297 commit 9cdb5f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 0 additions & 2 deletions examples/rails/.bundle/config

This file was deleted.

4 changes: 0 additions & 4 deletions examples/rails/src/config.ru

This file was deleted.

12 changes: 11 additions & 1 deletion examples/rails/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ async fn main() -> Result<(), http::Error> {

let controller = RackController::new("todo");

Server::new(vec![controller.wildcard("/")])
Server::new(vec![route!("/rust" => Index), controller.wildcard("/")])
.launch("0.0.0.0:8000")
.await
}

#[derive(Default)]
struct Index;

#[async_trait]
impl Controller for Index {
async fn handle(&self, request: &Request) -> Result<Response, Error> {
Ok(Response::new().html("<h1>This is served by Rust!</h1>"))
}
}

0 comments on commit 9cdb5f6

Please sign in to comment.