mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 11:54:40 +00:00
Bump warp and begin axum migration (#9001)
- Bump `warp` to 0.4. This unifies `warp` and `axum` onto the same `http`, `hyper`, `h2`, `rustls`, etc versions. - Create `axum_utils` which contain common functions and types - Begins migration of all HTTP API servers from warp to axum Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use reqwest::StatusCode;
|
||||
use warp::Rejection;
|
||||
|
||||
/// Convert from a "new" `http::StatusCode` to a `warp` compatible one.
|
||||
pub fn convert(code: StatusCode) -> Result<warp::http::StatusCode, Rejection> {
|
||||
code.as_u16().try_into().map_err(|e| {
|
||||
crate::reject::custom_server_error(format!("bad status code {code:?} - {e:?}"))
|
||||
})
|
||||
/// Convert a `reqwest::StatusCode` to a `warp::http::StatusCode`.
|
||||
///
|
||||
/// In warp 0.4, both `reqwest` (0.12) and `warp` use the `http` v1 crate,
|
||||
/// so `reqwest::StatusCode` and `warp::http::StatusCode` are the same type.
|
||||
/// This function is retained for API compatibility but is now a no-op.
|
||||
pub fn convert(code: StatusCode) -> Result<warp::http::StatusCode, warp::Rejection> {
|
||||
Ok(code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user