Skip to content

Commit

Permalink
add an endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeusgr committed Jan 4, 2024
1 parent a8c8523 commit 8c22fd4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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(say_hello))
// Here is where I add new functionality, right?
// adds the following router to the self:
.merge(SwaggerUi::new("/swagger-ui").url("/api-doc/openapi.json", ApiDoc::openapi()));
Expand All @@ -121,6 +122,9 @@ async fn main() -> Result<()> {
tokio::try_join!(app, app_metrics)?;
Ok(())
}
async fn say_hello() -> String {
return "Hello!".to_string();
}
// to serve means to run with a Router app at a port and address.
async fn serve(name: &str, app: Router, port: u16) -> Result<()> {
let bind_addr: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port);
Expand Down

0 comments on commit 8c22fd4

Please sign in to comment.