Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Oct 21, 2024
1 parent f08e0ff commit aa4c74b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,17 +594,17 @@ Either, by using the `headers` field in the `Response` object:
</Col>

<Col>
To prevent the headers from getting applied to certain endpoints, you can use the `response_headers_exclude` function.
To prevent the headers from getting applied to certain endpoints, you can use the `exclude_response_headers_for` function.
</Col>
<Col>
<CodeGroup title="Request" tag="GET" label="/hello_world">

```python {{ title: 'untyped' }}
app.response_headers_exclude(["/login", "/signup"])
app.exclude_response_headers_for(["/login", "/signup"])
```

```python {{title: 'typed'}}
app.response_headers_exclude(["/login", "/signup"])
app.exclude_response_headers_for(["/login", "/signup"])
```
</CodeGroup>

Expand Down
4 changes: 2 additions & 2 deletions robyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def set_request_header(self, key: str, value: str) -> None:
def set_response_header(self, key: str, value: str) -> None:
self.response_headers.set(key, value)

def response_headers_exclude(self, exclude_paths: Optional[List[str]]):
def exclude_response_headers_for(self, exclude_paths: Optional[List[str]]):
"""
To disable certain routes from the application of response headers
@param exclude_paths: the paths to exclude response headers from
Expand Down Expand Up @@ -247,7 +247,7 @@ def _add_openapi_routes(self, auth_required: bool = False):
is_const=True,
auth_required=auth_required,
)
self.response_headers_exclude(["/docs", "/openapi.json"])
self.exclude_response_headers_for(["/docs", "/openapi.json"])

def start(self, host: str = "127.0.0.1", port: int = 8080, _check_port: bool = True):
"""
Expand Down
14 changes: 7 additions & 7 deletions robyn/processpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_processes(
workers: int,
processes: int,
response_headers: Headers,
header_exclude_paths: Optional[List[str]],
response_header_exclude_paths: Optional[List[str]],
open_browser: bool,
) -> List[Process]:
socket = SocketHeld(url, port)
Expand All @@ -44,7 +44,7 @@ def run_processes(
workers,
processes,
response_headers,
header_exclude_paths,
response_header_exclude_paths,
)

def terminating_signal_handler(_sig, _frame):
Expand Down Expand Up @@ -78,7 +78,7 @@ def init_processpool(
workers: int,
processes: int,
response_headers: Headers,
header_exclude_paths: Optional[List[str]],
response_header_exclude_paths: Optional[List[str]],
) -> List[Process]:
process_pool = []
if sys.platform.startswith("win32") or processes == 1:
Expand All @@ -93,7 +93,7 @@ def init_processpool(
socket,
workers,
response_headers,
header_exclude_paths,
response_header_exclude_paths,
)

return process_pool
Expand All @@ -113,7 +113,7 @@ def init_processpool(
copied_socket,
workers,
response_headers,
header_exclude_paths,
response_header_exclude_paths,
),
)
process.start()
Expand Down Expand Up @@ -149,7 +149,7 @@ def spawn_process(
socket: SocketHeld,
workers: int,
response_headers: Headers,
header_exclude_paths: Optional[List[str]],
response_header_exclude_paths: Optional[List[str]],
):
"""
This function is called by the main process handler to create a server runtime.
Expand Down Expand Up @@ -179,7 +179,7 @@ def spawn_process(

server.apply_response_headers(response_headers)

server.set_response_header_exclude_paths(header_exclude_paths)
server.set_response_header_exclude_paths(response_header_exclude_paths)

for route in routes:
route_type, endpoint, function, is_const = route
Expand Down
6 changes: 3 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ async fn index(
payload: web::Payload,
const_router: web::Data<Arc<ConstRouter>>,
middleware_router: web::Data<Arc<MiddlewareRouter>>,
global_headers: (web::Data<Arc<Headers>>, web::Data<Arc<Headers>>),
global_request_response_headers: (web::Data<Arc<Headers>>, web::Data<Arc<Headers>>),
response_header_exclude_paths: web::Data<Option<Vec<String>>>,
req: HttpRequest,
) -> impl Responder {
let mut request = Request::from_actix_request(&req, payload, &global_headers.0).await;
let mut request = Request::from_actix_request(&req, payload, &global_request_response_headers.0).await;

// Before middleware
// Global
Expand Down Expand Up @@ -491,7 +491,7 @@ async fn index(

debug!("OG Response : {:?}", response);

response.headers.extend(&global_headers.1);
response.headers.extend(&global_request_response_headers.1);

match &response_header_exclude_paths.get_ref() {
None => {}
Expand Down

0 comments on commit aa4c74b

Please sign in to comment.