Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Nov 27, 2024
1 parent b29e483 commit 318324e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 57 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ members = [
"examples/request-tracking",
"examples/engine",
"rwf-admin",
"examples/files", "examples/rwf-web-app",
"examples/files",
]
exclude = ["examples/rails", "rwf-ruby", "examples/django", "rwf-fuzz"]
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Your application is ready. You can launch it with Cargo:
cargo run
```

Once the server is running, your web application will be available on [http://localhost:8000](http://localhost:8000). The full code for this is available on [GitHub](https://github.com/levkk/rwf/tree/main/examples/quick-start).
Once the server is running, your web application will be available at [http://localhost:8000](http://localhost:8000). The full code for this is available on [GitHub](https://github.com/levkk/rwf/tree/main/examples/quick-start).

## Learn more

Expand Down
31 changes: 8 additions & 23 deletions examples/quick-start/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use rwf::http::{self, Server};
use rwf::prelude::*;

#[derive(Default)]
struct Index;

#[async_trait]
impl Controller for Index {
async fn handle(&self, _request: &Request) -> Result<Response, Error> {
Ok(Response::new().html("<h1>My first Rwf app!</h1>"))
}
/// Simple controller.
#[controller]
async fn index() -> Response {
Response::new().html("<h1>My first Rwf app!</h1>")
}

/// More complex controller.
#[derive(Default)]
struct CurrentTime;

Expand All @@ -28,23 +25,11 @@ impl Controller for CurrentTime {
}
}

/// Simple controller.
#[controller]
async fn current_time() -> Response {
let time = OffsetDateTime::now_utc();

Response::new().text(format!("The current time is: {:?}", time))
}

#[tokio::main]
async fn main() -> Result<(), http::Error> {
Logger::init();

Server::new(vec![
route!("/" => Index),
route!("/time" => CurrentTime),
route!("/current-time" => current_time),
])
.launch("0.0.0.0:8001")
.await
Server::new(vec![route!("/" => index), route!("/time" => CurrentTime)])
.launch("0.0.0.0:8001")
.await
}
7 changes: 0 additions & 7 deletions examples/rwf-web-app/Cargo.toml

This file was deleted.

18 changes: 0 additions & 18 deletions examples/rwf-web-app/src/main.rs

This file was deleted.

0 comments on commit 318324e

Please sign in to comment.