From 20e46215fb132d48183f237b9107f1cd95eae854 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 7 Feb 2024 03:07:02 +0900 Subject: [PATCH] Update: `.header` docs, README, LICENSE year --- LICENSE | 2 +- README.md | 26 ++++++++++------------- ohkami/src/layer1_req_res/request/mod.rs | 6 +++--- ohkami/src/layer1_req_res/response/mod.rs | 6 +++--- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/LICENSE b/LICENSE index 54f1096d..b1003871 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 kanarus +Copyright (c) 2024 kanarus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/README.md b/README.md index 95e5d3f1..a38ee604 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ async fn main() { )).howl("localhost:5000").await } -async fn hello(name: &str) -> impl IntoResponse { +async fn hello(name: &str) -> String { format!("Hello, {name}!") } ``` @@ -209,7 +209,7 @@ async fn main() {
### testing -```rust,no_run +```rust use ohkami::prelude::*; use ohkami::testing::*; // <-- @@ -217,27 +217,23 @@ fn hello_ohkami() -> Ohkami { Ohkami::new(( "/hello".GET(|| async move { OK("Hello, world!") - }) + }), )) } -#[tokio::main] -async fn main() { - hello_ohkami() - .howl(5050).await -} - #[cfg(test)] #[tokio::test] async fn test_my_ohkami() { - let hello_ohkami = hello_ohkami(); + let ho = hello_ohkami(); - let res = hello_ohkami.oneshot(TestRequest::GET("/")).await; - assert_eq!(res.status, http::Status::NotFound); + let req = TestRequest::GET("/"); + let res = ho.oneshot(req).await; + assert_eq!(res.status(), Status::NotFound); - let res = hello_ohkami.oneshot(TestRequest::GET("/hello")).await; - assert_eq!(res.status, http::Status::OK); - assert_eq!(res.content.unwrap().text(), Some("Hello, world!")); + let req = TestRequest::GET("/hello"); + let res = ho.oneshot(req).await; + assert_eq!(res.status(), Status::OK); + assert_eq!(res.text(), Some("Hello, world!")); } ``` diff --git a/ohkami/src/layer1_req_res/request/mod.rs b/ohkami/src/layer1_req_res/request/mod.rs index 6a01574d..d99799f7 100644 --- a/ohkami/src/layer1_req_res/request/mod.rs +++ b/ohkami/src/layer1_req_res/request/mod.rs @@ -87,9 +87,9 @@ pub struct Request {pub(crate) _metadata: [u8; METADATA_SIZE], method: Method, /// Headers of this request /// - /// - `.headers.{HeaderName}()` to get the value - /// - `.headers.set().{HeaderName}(〜)` to mutate the value - /// - `.headers.set().{HeaderName}(append(〜))` to append the value + /// - `.{HeaderName}()` to get the value + /// - `.set().{HeaderName}(〜)` to mutate the value + /// - `.set().{HeaderName}(append(〜))` to append the value pub headers: RequestHeaders, pub(crate) path: Path, queries: QueryParams, diff --git a/ohkami/src/layer1_req_res/response/mod.rs b/ohkami/src/layer1_req_res/response/mod.rs index ee5bb5d6..f3a54670 100644 --- a/ohkami/src/layer1_req_res/response/mod.rs +++ b/ohkami/src/layer1_req_res/response/mod.rs @@ -72,9 +72,9 @@ pub struct Response { pub status: Status, /// Headers of this response /// - /// - `.headers.{HeaderName}()` to get the value - /// - `.headers.set().{HeaderName}(〜)` to set the value - /// - `.headers.set().{HeaderName}(append(〜))` to append the value + /// - `.{HeaderName}()` to get the value + /// - `.set().{HeaderName}(〜)` to set the value + /// - `.set().{HeaderName}(append(〜))` to append the value pub headers: ResponseHeaders, pub(crate) content: Option>, } const _: () = {