Skip to content

Commit

Permalink
add handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeusgr committed Jan 5, 2024
1 parent 86094d8 commit dbc3e68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/handlers/my.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
use axum::{
Json,
response::{Html, IntoResponse},
http::{StatusCode, Uri, header::{self, HeaderMap, HeaderName}},
};

// this is a handler, a function that is used in a Router
// integrate new functionality here:
// TODO: A | B example: serve a stream. roadmap - show webcam on laptop screen.
// A handler is an async function that accepts zero or more “extractors” as arguments and returns something that can be converted into a response.
pub async fn say_hello() -> String {
// integrate new functionality here:
return "Hello!!!".to_string();
}

pub async fn html() -> Html<&'static str> {
Html("<p>Hello, World!</p>")
}
// stream.
// roadmap - show webcam on laptop screen.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async fn main() -> Result<()> {
.layer(CatchPanicLayer::custom(runtime::catch_panic))
// Mark headers as sensitive on both requests and responses.
.layer(SetSensitiveHeadersLayer::new([header::AUTHORIZATION]))
.route("/say-hello", get(handlers::my::say_hello)) // change handler
.route("/say-hello", get(handlers::my::html)) // change handler
// adds the following router to the self:
.merge(SwaggerUi::new("/swagger-ui").url("/api-doc/openapi.json", ApiDoc::openapi()));
//TODO: test layers.
Expand Down

0 comments on commit dbc3e68

Please sign in to comment.