Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document early_request_filter #72

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/user_guide/phase.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ The pingora-proxy HTTP proxy framework supports highly programmable proxy behavi
Pingora-proxy allows users to insert arbitrary logic into the life of a request.
```mermaid
graph TD;
start("new request")-->request_filter;
start("new request")-->early_request_filter;
early_request_filter-->request_filter;
request_filter-->upstream_peer;

upstream_peer-->Connect{{IO: connect to upstream}};
Expand Down Expand Up @@ -52,9 +53,12 @@ Pingora-proxy allows users to insert arbitrary logic into the life of a request.
* The reason both `upstream_response_*_filter()` and `response_*_filter()` exist is for HTTP caching integration reasons (still WIP).


### `request_filter()`
### `early_request_filter()`
This is the first phase of every request.

This function is similar to `request_filter()` but executes before any other logic, including downstream module logic. The main purpose of this function is to provide finer-grained control of the behavior of the modules.

### `request_filter()`
This phase is usually for validating request inputs, rate limiting, and initializing context.

### `proxy_upstream_filter()`
Expand Down
3 changes: 2 additions & 1 deletion docs/user_guide/phase_chart.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Pingora proxy phases without caching
```mermaid
graph TD;
start("new request")-->request_filter;
start("new request")-->early_request_filter;
early_request_filter-->request_filter;
request_filter-->upstream_peer;

upstream_peer-->Connect{{IO: connect to upstream}};
Expand Down
6 changes: 3 additions & 3 deletions pingora-proxy/src/proxy_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ pub trait ProxyHttp {

/// Handle the incoming request before any downstream module is executed.
///
/// This function is similar to [Self::request_filter()] but execute before any other logic
/// especially the downstream modules. The main purpose of this function is to provide finer
/// grained control of behavior of the modules.
/// This function is similar to [Self::request_filter()] but executes before any other logic,
/// including downstream module logic. The main purpose of this function is to provide finer
/// grained control of the behavior of the modules.
///
/// Note that because this function is executed before any module that might provide access
/// control or rate limiting, logic should stay in request_filter() if it can in order to be
Expand Down
Loading