Skip to content

Commit

Permalink
Release v0.49.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Dec 11, 2023
1 parent df9d1a1 commit 2e541d9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 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 = "robyn"
version = "0.48.0"
version = "0.49.0"
authors = ["Sanskar Jethi <[email protected]>"]
edition = "2021"
description = "A web server that is fast!"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "robyn"
version = "0.48.0"
version = "0.49.0"
description = "A High-Performance, Community-Driven, and Innovator Friendly Web Framework with a Rust runtime."
authors = [{ name = "Sanskar Jethi", email = "[email protected]" }]
repository = "https://github.com/sparckles/robyn"
Expand Down Expand Up @@ -43,7 +43,7 @@ Changelog = "https://github.com/sparckles/robyn/blob/main/CHANGELOG.md"

[tool.poetry]
name = "robyn"
version = "0.48.0"
version = "0.49.0"
description = "A High-Performance, Community-Driven, and Innovator Friendly Web Framework with a Rust runtime."
authors = ["Sanskar Jethi <[email protected]>"]

Expand Down
12 changes: 8 additions & 4 deletions src/executors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[deny(clippy::if_same_then_else)]
/// This is the module that has all the executor functions
/// i.e. the functions that have the responsibility of parsing and executing functions.
pub mod web_socket_executors;
Expand Down Expand Up @@ -31,21 +32,24 @@ where
match function.number_of_params {
0 => handler.call0(),
1 => {
if function.args.as_ref(py).get_item("request").is_some() {
handler.call1((function_args,))
} else if function.args.as_ref(py).get_item("response").is_some() {
// this is for middlewares
if function.args.as_ref(py).get_item("request").is_some()
|| function.args.as_ref(py).get_item("response").is_some()
{
// If 'request' is present, call handler with 'function_args'
handler.call1((function_args,))
} else {
// If neither 'request' nor 'response' is present
handler.call((), Some(kwargs))
}
}
2 => {
if function.args.as_ref(py).get_item("request").is_some()
|| function.args.as_ref(py).get_item("response").is_some()
{
// If either 'request' or 'response' is present, call handler with 'function_args' and 'kwargs'
handler.call((function_args,), Some(kwargs))
} else {
// If neither 'request' nor 'response' is present
handler.call((), Some(kwargs))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ async fn index(
request.path_params = route_params;
}
for before_middleware in before_middlewares {
request = match execute_middleware_function(&mut request, &before_middleware).await {
request = match execute_middleware_function(&request, &before_middleware).await {
Ok(MiddlewareReturn::Request(r)) => r,
Ok(MiddlewareReturn::Response(r)) => {
// If a before middleware returns a response, we abort the request and return the response
Expand Down Expand Up @@ -449,7 +449,7 @@ async fn index(
after_middlewares.push(function);
}
for after_middleware in after_middlewares {
response = match execute_middleware_function(&mut response, &after_middleware).await {
response = match execute_middleware_function(&response, &after_middleware).await {
Ok(MiddlewareReturn::Request(_)) => {
error!("After middleware returned a request");
return Response::internal_server_error(Some(&response.headers));
Expand Down
13 changes: 3 additions & 10 deletions src/types/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Headers {
debug!("Setting header {} to {}", key, value);
self.headers
.entry(key.to_lowercase())
.or_insert_with(Vec::new)
.or_default()
.push(value);
}

Expand Down Expand Up @@ -105,10 +105,7 @@ impl Headers {
self.headers.entry(key).or_insert_with(Vec::new).push(value);
} else {
let value: Vec<String> = new_value.unwrap().iter().map(|x| x.to_string()).collect();
self.headers
.entry(key)
.or_insert_with(Vec::new)
.extend(value);
self.headers.entry(key).or_default().extend(value);
}
}
}
Expand Down Expand Up @@ -167,11 +164,7 @@ impl Headers {
for (key, value) in req_headers {
let key = key.to_string().to_lowercase();
let value = value.to_str().unwrap().to_string();
headers
.headers
.entry(key)
.or_insert_with(Vec::new)
.push(value);
headers.headers.entry(key).or_default().push(value);
}

headers
Expand Down
2 changes: 1 addition & 1 deletion src/types/multimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl QueryParams {

pub fn set(&mut self, key: String, value: String) {
debug!("Setting key: {} to value: {}", key, value);
self.queries.entry(key).or_insert_with(Vec::new).push(value);
self.queries.entry(key).or_default().push(value);
debug!("Multimap: {:?}", self.queries);
}

Expand Down

0 comments on commit 2e541d9

Please sign in to comment.