Skip to content

Commit

Permalink
[#161] index 문서 코멘트 보완
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Oct 10, 2024
1 parent 3ed78a8 commit c0aeee4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions rupring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,43 @@ fn main() {
# Request
- rupring defines HTTP Request through [crate::request::Request] type and provides convenient request processing using macros.
```rust
#[rupring::Get(path = /:id)]
pub fn hello(request: rupring::Request) -> rupring::Response {
let method = request.method;
assert_eq!(method, rupring::Method::GET);
let path = request.path;
assert_eq!(path, "/");
let body = request.body;
assert_eq!(body, "");
let headers = request.headers;
let content_type = headers.get("content-type").unwrap();
assert_eq!(content_type, "text/plain");
let id = request.path_parameters["id"].clone();
assert_eq!(id, "123");
let query = request.query_parameters["query"].clone();
assert_eq!(query, vec!["asdf".to_string()]);
//...
response
}
```
- Please refer to the corresponding [document](crate::request) for more details.
# Response
- rupring defines HTTP Response through [crate::response::Response] type and provides convenient response processing using macros.
```rust
#[rupring::Get(path = /)]
pub fn hello(_request: rupring::Request) -> rupring::Response {
rupring::Response::new().text("Hello, World!".to_string())
}
```
- Please refer to the corresponding [document](crate::response) for more details.
# Middleware
Expand Down

0 comments on commit c0aeee4

Please sign in to comment.