forge
Explore
Log in

Don't you dare go Hollow

🔌 one routes! per path in the ai nest (two GETs cannot share one)

Browse files at this commit

712ff31f765f7a4b37f604b0c40863b440fc9cf0Ahmet Kaan GümüşParent: 5176550
  • fix
    • 🔌 one routes! per path in the ai nest (two GETs cannot share one)
Show full message
fix: 🔌 one routes! per path in the ai nest (two GETs cannot share one)
src/web/ai.rsmodified+11 -2
@@ -1,5 +1,9 @@
1 //! Public discovery for the AI bridge.1 //! Public discovery for the AI bridge.
2 //!2 //!
3+//! Two reads: the bridge's certificate, which a service needs before it can
4+//! dial in, and the capabilities currently on offer, which a client needs
5+//! before it offers an AI feature it cannot get an answer from.
6+//!
3 //! An AI service needs the bridge's certificate before it can dial in, and the7 //! An AI service needs the bridge's certificate before it can dial in, and the
4 //! certificate is regenerated on every boot when no PEM pair is configured. So8 //! certificate is regenerated on every boot when no PEM pair is configured. So
5 //! it is published here: the service fetches this over HTTP, pins what it gets,9 //! it is published here: the service fetches this over HTTP, pins what it gets,
@@ -14,6 +18,8 @@
14 //! network, put a real certificate in `AI_TLS_CERT`/`AI_TLS_KEY` and distribute18 //! network, put a real certificate in `AI_TLS_CERT`/`AI_TLS_KEY` and distribute
15 //! it out of band.19 //! it out of band.
16 20
21+use std::collections::BTreeMap;
22+
17 use axum::Json;23 use axum::Json;
18 use axum::extract::State;24 use axum::extract::State;
19 use base64::Engine;25 use base64::Engine;
@@ -27,10 +33,13 @@ use crate::constant::AI_PROTOCOL;
27 use crate::error::{AppError, ErrorResponse};33 use crate::error::{AppError, ErrorResponse};
28 use crate::state::AppState;34 use crate::state::AppState;
29 use crate::web::CurrentUser;35 use crate::web::CurrentUser;
30-use std::collections::BTreeMap;
31 36
32 pub fn routes() -> OpenApiRouter<AppState> {37 pub fn routes() -> OpenApiRouter<AppState> {
33- OpenApiRouter::new().routes(routes!(bridge_certificate, capabilities))38+ // One `routes!` per path: the multi-handler form groups methods under a
39+ // single path, so two `get` handlers never share one.
40+ OpenApiRouter::new()
41+ .routes(routes!(bridge_certificate))
42+ .routes(routes!(capabilities))
34 }43 }
35 44
36 /// Everything a service needs to reach the bridge, except the shared token45 /// Everything a service needs to reach the bridge, except the shared token