fix: axum middlewares only handles routes that are registered

r0.6
Meng Zhang 2023-11-23 09:16:57 +08:00
parent 063678bfa6
commit 3bddd9fa64
1 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@ use std::{sync::Arc, time::Duration};
use axum::{routing, Router}; use axum::{routing, Router};
use clap::Args; use clap::Args;
use hyper::StatusCode;
use tabby_common::{ use tabby_common::{
api, api,
api::{code::CodeSearch, event::EventLogger}, api::{code::CodeSearch, event::EventLogger},
@ -192,6 +193,13 @@ async fn api_router(
config.server.completion_timeout, config.server.completion_timeout,
))) )))
}); });
} else {
routers.push({
Router::new().route(
"/v1/completions",
routing::post(StatusCode::NOT_IMPLEMENTED),
)
})
} }
if let Some(chat_state) = chat_state { if let Some(chat_state) = chat_state {
@ -201,6 +209,13 @@ async fn api_router(
routing::post(routes::chat_completions).with_state(chat_state), routing::post(routes::chat_completions).with_state(chat_state),
) )
}) })
} else {
routers.push({
Router::new().route(
"/v1beta/chat/completions",
routing::post(StatusCode::NOT_IMPLEMENTED),
)
})
} }
routers.push({ routers.push({