Skip to content

Commit

Permalink
chore: bump version to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shellfly committed Jan 29, 2023
1 parent 39fbfb3 commit 1e2ede6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "haro"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
description = "A simple and synchronous web framework written in and for Rust"
license = "MIT OR Apache-2.0"
Expand Down
18 changes: 17 additions & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use haro::{db, middleware, Application, DynHandler, Request, Response};
use haro::{db, middleware, Application, DynHandler, Handler, Request, Response};
use http::StatusCode;
use serde::{Deserialize, Serialize};
use serde_json::json;
Expand All @@ -9,16 +9,23 @@ fn test_app() {
db::SQLite::init("test.db");

let mut app = Application::new("0:8080");
let hello_handler = HelloHandler {
name: "Haro".to_string(),
};
app.middleware(middleware::logging);
app.middleware(my_middleware);
app.route("/", index);
app.route_handler("/hello", hello_handler);
app.route("/hello/:name", hello);
app.route("/input", input);
app.route("/sqlite", sqlite);

let res = app.request("get", "/", HashMap::new(), &Vec::new());
assert_eq!("Hello Haro".as_bytes(), res.body());

let res = app.request("get", "/hello", HashMap::new(), &Vec::new());
assert_eq!("Hello Haro".as_bytes(), res.body());

let res = app.request("get", "/hello/world", HashMap::new(), &Vec::new());
assert_eq!("{\"name\":\"world\"}".as_bytes(), res.body());

Expand All @@ -37,6 +44,15 @@ struct Person {
name: String,
}

struct HelloHandler {
name: String,
}
impl Handler for HelloHandler {
fn call(&self, _: Request) -> Response {
Response::str(format!("Hello {}", self.name))
}
}

fn index(_: Request) -> Response {
Response::str("Hello Haro")
}
Expand Down

0 comments on commit 1e2ede6

Please sign in to comment.