Skip to content

Commit e97166c

Browse files
committed
feat: rename to Haro
1 parent cf5f949 commit e97166c

File tree

17 files changed

+80
-91
lines changed

17 files changed

+80
-91
lines changed

Cargo.lock

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
2-
name = "web"
2+
name = "haro"
33
version = "0.1.0"
44
edition = "2021"
55
description = "A simple and synchronous web framework written in and for Rust"
66
license = "MIT OR Apache-2.0"
7-
repository = "https://github.com/shellfly/web.rs/"
7+
repository = "https://github.com/shellfly/haro/"
88
keywords = ["http", "web", "framework"]
99
categories = ["network-programming", "web-programming::http-server"]
1010

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# web.rs
1+
# Haro
22

3-
**web.rs** is a **simple** and **synchronous** web framework written in and for Rust.
3+
**Haro** is a **simple** and **synchronous** web framework written in and for Rust.
44

5-
The application interface was inspired by the [web.py](https://webpy.org/) project.
5+
The project was named after the [Haro character](https://en.wikipedia.org/wiki/Haro_(character)). The application interface was inspired by the [web.py](https://webpy.org/) project.
66

77
## Motivation
88
> In short, async Rust is more difficult to use and can result in a higher maintenance burden than synchronous Rust, but gives you best-in-class performance in return. All areas of async Rust are constantly improving, so the impact of these issues will wear off over time
99
>
1010
> https://rust-lang.github.io/async-book/01_getting_started/03_state_of_async_rust.html
1111
12-
As the async book says, while bringing performance, async Rust can result in a higher maintenance burden. The goal of this project is to create a simple and minimum synchronous Web framework for Rust.
12+
As the async book says, async Rust is not mature yet. While bringing performance, it also results in a higher maintenance burden. The goal of this project is to create a simple and minimum synchronous Web framework for Rust.
1313

1414
## Quick Start
1515

16-
Add `web` as a dependency by cargo
16+
Add `haro` as a dependency by cargo
1717
```bash
18-
cargo add web
18+
cargo add haro
1919
```
2020

2121
Then, on your main.rs:
2222

2323
```Rust
24-
use web::{Application, Request, Response};
24+
use haro::{Application, Request, Response};
2525

2626
fn main() {
2727
let mut app = Application::new("0:8000");
@@ -31,7 +31,7 @@ fn main() {
3131
}
3232

3333
fn index(_: Request) -> Response {
34-
Response::str("Hello web.rs")
34+
Response::str("Hello Haro")
3535
}
3636

3737
fn hello(req: Request) -> Response {
@@ -51,7 +51,7 @@ HTTP/1.1 200 OK
5151
content-length: 12
5252
content-type: text/plain
5353

54-
Hello web.rs
54+
Hello Haro
5555
```
5656

5757
```bash
@@ -76,7 +76,7 @@ content-type: application/json
7676

7777
## More Examples
7878

79-
The repo contains [some examples](./examples) that show how to put all the pieces together.
79+
The repo contains [more examples](./examples) that show how to put all the pieces together.
8080

8181
## Features
8282

examples/cookie/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use cookie::Cookie;
44
use http::header::SET_COOKIE;
55
use serde_json::json;
6-
use web::{
6+
use haro::{
77
middleware::{self, DynHandler},
88
Application, Request, Response,
99
};
@@ -18,7 +18,7 @@ fn main() {
1818
}
1919

2020
fn index(_: Request) -> Response {
21-
Response::str("Hello web.rs")
21+
Response::str("Hello Haro")
2222
}
2323

2424
fn hello(req: Request) -> Response {

examples/database/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// NOTE: add `web` crate with `full` or `database` feature flag to use database utilities.
1+
// NOTE: add `haro` crate with `full` or `database` feature flag to use database utilities.
22

3+
use haro::{db, Application, Request, Response};
34
use mysql::prelude::*;
45
use serde::{Deserialize, Serialize};
5-
use web::{db, Application, Request, Response};
66

77
fn main() {
8-
db::Postgres::init("postgres://postgres:postgres@localhost:5432/test");
8+
db::Postgres::init("postgres://postgres:postgres@localhost:5432/ci");
99
db::MySQL::init("mysql://root:root@localhost:3306/test");
1010
db::SQLite::init("test.db");
1111

examples/hello_world/index.html

-12
This file was deleted.

examples/hello_world/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use haro::{Application, Request, Response};
12
use serde_json::json;
2-
use web::{Application, Request, Response};
33

44
fn main() {
55
let mut app = Application::new("0:8080");
@@ -10,7 +10,7 @@ fn main() {
1010
}
1111

1212
fn index(_: Request) -> Response {
13-
Response::str("Hello web.rs")
13+
Response::str("Hello Haro")
1414
}
1515

1616
fn hello(req: Request) -> Response {

examples/middleware/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::sync::Arc;
22

3-
use serde_json::json;
4-
use web::{
3+
use haro::{
54
middleware::{self, DynHandler},
65
Application, Request, Response,
76
};
7+
use serde_json::json;
88

99
fn main() {
1010
let mut app = Application::new("0:8080");
@@ -16,7 +16,7 @@ fn main() {
1616
}
1717

1818
fn index(_: Request) -> Response {
19-
Response::str("Hello web.rs")
19+
Response::str("Hello Haro")
2020
}
2121

2222
fn hello(req: Request) -> Response {

examples/template/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// NOTE: add `web` crate with `full` or `template` feature flag to use database utilities.
1+
// NOTE: add `haro` crate with `full` or `template` feature flag to use database utilities.
22

33
use tera::Context;
4-
use web::{Application, Request, Response};
4+
use haro::{Application, Request, Response};
55

66
fn main() {
77
let mut app = Application::new("0:8080");
@@ -12,7 +12,7 @@ fn main() {
1212
}
1313

1414
fn index(_: Request) -> Response {
15-
Response::str("Hello web.rs")
15+
Response::str("Hello Haro")
1616
}
1717

1818
fn tmpl(req: Request) -> Response {

examples/test/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use haro::{Application, Request, Response};
12
use serde_json::json;
2-
use web::{Application, Request, Response};
33

44
fn main() {
55
let app = build_app();
@@ -15,7 +15,7 @@ fn build_app() -> Application {
1515
}
1616

1717
fn index(_: Request) -> Response {
18-
Response::str("Hello web.rs")
18+
Response::str("Hello Haro")
1919
}
2020

2121
fn hello(req: Request) -> Response {
@@ -38,6 +38,6 @@ mod tests {
3838
fn it_works() {
3939
let app = build_app();
4040
let res = app.request("get", "/", HashMap::new(), &Vec::new());
41-
assert_eq!("Hello web.rs".as_bytes(), res.body());
41+
assert_eq!("Hello Haro".as_bytes(), res.body());
4242
}
4343
}

src/app.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Application {
2424
/// Create a new `Application` instance
2525
/// # Examples
2626
/// ```
27-
/// use web::Application;
27+
/// use haro::Application;
2828
///
2929
/// let mut app = Application::new("0:12345");
3030
/// ```
@@ -44,7 +44,7 @@ impl Application {
4444
/// Set thread worker pool size for `Application`
4545
/// # Examples
4646
/// ```
47-
/// use web::Application;
47+
/// use haro::Application;
4848
///
4949
/// let mut app = Application::new("0:8080").num_threads(64);
5050
/// ```
@@ -56,7 +56,7 @@ impl Application {
5656
/// Add a middleware into an `Application`
5757
/// # Example
5858
/// ```
59-
/// use web::{Application, middleware};
59+
/// use haro::{Application, middleware};
6060
///
6161
/// let mut app = Application::new("0:8080");
6262
/// app.middleware(middleware::logging);
@@ -68,13 +68,13 @@ impl Application {
6868
/// Add a route into an `Application`
6969
/// # Example
7070
/// ```
71-
/// use web::{Application, Request, Response, middleware};
71+
/// use haro::{Application, Request, Response, middleware};
7272
///
7373
/// let mut app = Application::new("0:8080");
7474
/// app.route("/", index);
7575
///
7676
/// fn index(_:Request) -> Response {
77-
/// Response::str("hello web.rs")
77+
/// Response::str("Hello Haro")
7878
/// }
7979
/// ```
8080
pub fn route(&mut self, pattern: &'static str, handler: Handler) {
@@ -85,7 +85,7 @@ impl Application {
8585
/// # Examples
8686
/// ```
8787
/// use std::collections::HashMap;
88-
/// use web::{Application, Request, Response};
88+
/// use haro::{Application, Request, Response};
8989
///
9090
/// fn test_handler(_:Request) -> Response {
9191
/// Response::str("test")
@@ -121,7 +121,7 @@ impl Application {
121121
/// # Examples
122122
/// ```
123123
/// use std::collections::HashMap;
124-
/// use web::{Application, Request, Response};
124+
/// use haro::{Application, Request, Response};
125125
///
126126
/// fn test_handler(_:Request) -> Response {
127127
/// Response::str("test")

src/db.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl Postgres {
1616
/// Initialize a global Postgres connection pool by provided `url`
1717
/// # Example
1818
/// ```no_run
19-
/// use web::db;
19+
/// use haro::db;
2020
///
2121
/// db::Postgres::init("postgres://postgres:postgres@localhost:5432/test")
2222
/// ```
@@ -29,7 +29,7 @@ impl Postgres {
2929
/// Retrieve a connection from the global Postgres connection pool
3030
/// # Example
3131
/// ```no_run
32-
/// use web::db;
32+
/// use haro::db;
3333
///
3434
/// let client = db::Postgres::get();
3535
/// ```
@@ -45,7 +45,7 @@ impl MySQL {
4545
/// Initialize a global MySQL connection pool by provided `url`
4646
/// # Example
4747
/// ```no_run
48-
/// use web::db;
48+
/// use haro::db;
4949
///
5050
/// db::MySQL::init("mysql://root:root@localhost:3306/test")
5151
/// ```
@@ -60,7 +60,7 @@ impl MySQL {
6060
/// Retrieve a connection from the global MySQL connection pool
6161
/// # Example
6262
/// ```no_run
63-
/// use web::db;
63+
/// use haro::db;
6464
///
6565
/// let client = db::MySQL::get();
6666
/// ```
@@ -76,7 +76,7 @@ impl SQLite {
7676
/// Initialize a global SQLite connection pool by provided `url`
7777
/// # Example
7878
/// ```no_run
79-
/// use web::db;
79+
/// use haro::db;
8080
///
8181
/// db::SQLite::init("test.db")
8282
/// ```
@@ -89,7 +89,7 @@ impl SQLite {
8989
/// Retrieve a connection from the global SQLite connection pool
9090
/// # Example
9191
/// ```no_run
92-
/// use web::db;
92+
/// use haro::db;
9393
///
9494
/// let client = db::SQLite::get();
9595
/// ```

src/http/request.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Request {
2626
/// # Example
2727
/// ```
2828
/// use std::collections::HashMap;
29-
/// use web::Request;
29+
/// use haro::Request;
3030
///
3131
/// let headers = HashMap::new();
3232
/// let body = &Vec::new();
@@ -107,6 +107,7 @@ impl Request {
107107
data = match content_type.as_str() {
108108
"application/json" => parse_json_body(req.body()),
109109
_ => {
110+
// TODO: support more content types
110111
warn!("unsupported content type {}", content_type);
111112
HashMap::new()
112113
}

0 commit comments

Comments
 (0)