Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Mar 4, 2021
1 parent 52a98a8 commit 7c350c7
Show file tree
Hide file tree
Showing 6 changed files with 575 additions and 580 deletions.
1 change: 0 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
tab_spaces = 2
edition="2018"
reorder_imports=true
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "httprouter"
version = "0.2.0"
version = "0.3.0"
license = "MIT"
authors = ["ibraheem <ibrah1440@gmail.com>"]
edition = "2018"
Expand All @@ -12,7 +12,8 @@ readme = "README.md"

[dependencies]
hyper = "0.13.9"
matchit = "0.2.0"
futures-util = { version = "0.3", default-features = false }
matchit = "0.3"

[dev-dependencies]
hyper = "0.13.9"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HttpRouter

[![Documentation](https://img.shields.io/badge/docs-0.2.0-4d76ae?style=for-the-badge)](https://docs.rs/httprouter/0.2.0)
[![Documentation](https://img.shields.io/badge/docs-0.3.0-4d76ae?style=for-the-badge)](https://docs.rs/httprouter/0.3.0)
[![Version](https://img.shields.io/crates/v/httprouter?style=for-the-badge)](https://crates.io/crates/httprouter)
[![License](https://img.shields.io/crates/l/httprouter?style=for-the-badge)](https://crates.io/crates/httprouter)
[![Actions](https://img.shields.io/github/workflow/status/ibraheemdev/httprouter-rs/Rust/master?style=for-the-badge)](https://github.com/ibraheemdev/httprouter-rs/actions)
Expand Down Expand Up @@ -38,7 +38,7 @@ async fn index(_: Request<Body>) -> Result<Response<Body>, Error> {
async fn hello(req: Request<Body>) -> Result<Response<Body>, Error> {
let params = req.extensions().get::<Params>().unwrap();
Ok(Response::new(format!("Hello, {}", params.by_name("user").unwrap()).into()))
Ok(Response::new(format!("Hello, {}", params.get("user").unwrap()).into()))
}
#[tokio::main]
Expand Down Expand Up @@ -117,9 +117,9 @@ use std::collections::HashMap;
use std::convert::Infallible;
use std::sync::Arc;
pub struct HostSwitch(HashMap<String, Router>);
pub struct HostSwitch<'a>(HashMap<String, Router<'a>>);
impl HostSwitch {
impl HostSwitch<'_> {
async fn serve(&self, req: Request<Body>) -> hyper::Result<Response<Body>> {
let forbidden = Response::builder()
.status(StatusCode::FORBIDDEN)
Expand Down
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![deny(rust_2018_idioms)]

//! # HttpRouter
//!
//! [![Documentation](https://img.shields.io/badge/docs-0.2.0-4d76ae?style=for-the-badge)](https://docs.rs/httprouter/0.2.0)
//! [![Documentation](https://img.shields.io/badge/docs-0.3.0-4d76ae?style=for-the-badge)](https://docs.rs/httprouter/0.3.0)
//! [![Version](https://img.shields.io/crates/v/httprouter?style=for-the-badge)](https://crates.io/crates/httprouter)
//! [![License](https://img.shields.io/crates/l/httprouter?style=for-the-badge)](https://crates.io/crates/httprouter)
//! [![Actions](https://img.shields.io/github/workflow/status/ibraheemdev/httprouter-rs/Rust/master?style=for-the-badge)](https://github.com/ibraheemdev/httprouter-rs/actions)
Expand Down Expand Up @@ -38,7 +40,7 @@
//!
//! async fn hello(req: Request<Body>) -> Result<Response<Body>, Error> {
//! let params = req.extensions().get::<Params>().unwrap();
//! Ok(Response::new(format!("Hello, {}", params.by_name("user").unwrap()).into()))
//! Ok(Response::new(format!("Hello, {}", params.get("user").unwrap()).into()))
//! }
//!
//! #[tokio::main]
Expand Down Expand Up @@ -117,9 +119,9 @@
//! use std::convert::Infallible;
//! use std::sync::Arc;
//!
//! pub struct HostSwitch(HashMap<String, Router>);
//! pub struct HostSwitch<'a>(HashMap<String, Router<'a>>);
//!
//! impl HostSwitch {
//! impl HostSwitch<'_> {
//! async fn serve(&self, req: Request<Body>) -> hyper::Result<Response<Body>> {
//! let forbidden = Response::builder()
//! .status(StatusCode::FORBIDDEN)
Expand Down Expand Up @@ -213,12 +215,12 @@ pub use matchit::Params;
// test the code examples in README.md
#[cfg(doctest)]
mod test_readme {
macro_rules! doc_comment {
macro_rules! doc_comment {
($x:expr) => {
#[doc = $x]
extern {}
};
}

doc_comment!(include_str!("../README.md"));
doc_comment!(include_str!("../README.md"));
}
Loading

0 comments on commit 7c350c7

Please sign in to comment.