Move api_root to global scope
This commit is contained in:
parent
d3323ac7ac
commit
c474d7b454
1 changed files with 43 additions and 43 deletions
|
|
@ -592,25 +592,7 @@ async fn update_session_ratelimits(
|
|||
Ok(Json(EmptyJsonResponse {}))
|
||||
}
|
||||
|
||||
impl HttpApi {
|
||||
pub fn new(api: Api, opts: Option<HttpApiOptions>) -> Self {
|
||||
Self {
|
||||
api,
|
||||
opts: opts.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the HTTP server forever on the given address.
|
||||
/// If read_only is passed, no state-modifying methods will be exposed.
|
||||
#[inline(never)]
|
||||
pub fn make_http_api_and_run(
|
||||
self,
|
||||
listener: TcpListener,
|
||||
upnp_router: Option<Router>,
|
||||
) -> BoxFuture<'static, anyhow::Result<()>> {
|
||||
let state = Arc::new(self);
|
||||
|
||||
let api_root = move |parts: Parts| async move {
|
||||
async fn api_root(parts: Parts) -> impl IntoResponse {
|
||||
// If browser, and webui enabled, redirect to web
|
||||
#[cfg(feature = "webui")]
|
||||
{
|
||||
|
|
@ -651,7 +633,25 @@ impl HttpApi {
|
|||
"version": env!("CARGO_PKG_VERSION"),
|
||||
})),
|
||||
).into_response()
|
||||
};
|
||||
}
|
||||
|
||||
impl HttpApi {
|
||||
pub fn new(api: Api, opts: Option<HttpApiOptions>) -> Self {
|
||||
Self {
|
||||
api,
|
||||
opts: opts.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the HTTP server forever on the given address.
|
||||
/// If read_only is passed, no state-modifying methods will be exposed.
|
||||
#[inline(never)]
|
||||
pub fn make_http_api_and_run(
|
||||
self,
|
||||
listener: TcpListener,
|
||||
upnp_router: Option<Router>,
|
||||
) -> BoxFuture<'static, anyhow::Result<()>> {
|
||||
let state = Arc::new(self);
|
||||
|
||||
let mut app = Router::new()
|
||||
.route("/", get(api_root))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue