api start
parent
ddea3b51bb
commit
766cf9ea0c
|
|
@ -15,4 +15,5 @@ serde_json = "1.0.140"
|
||||||
tokio = { version = "1.45.1", features = ["full"] }
|
tokio = { version = "1.45.1", features = ["full"] }
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
|
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
||||||
utoipa-axum = "0.2.0"
|
utoipa-axum = "0.2.0"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
use crate::endpoints::rest::__path_model_rest_handler;
|
||||||
|
|
||||||
|
#[derive(utoipa::OpenApi)]
|
||||||
|
#[openapi(paths(model_rest_handler))]
|
||||||
|
struct ApiDoc;
|
||||||
|
|
@ -19,6 +19,17 @@ pub mod rest {
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
use super::{IntoResponse, StatusCode, InputMetric, Json, Config, State};
|
use super::{IntoResponse, StatusCode, InputMetric, Json, Config, State};
|
||||||
|
|
||||||
|
#[utoipa::path(
|
||||||
|
get,
|
||||||
|
path = "/api/metrics/rest",
|
||||||
|
responses(
|
||||||
|
(status = 200, description = "Model successfully processed all given data and"),
|
||||||
|
(status = 500, description = "Some errors with model")
|
||||||
|
),
|
||||||
|
params(
|
||||||
|
("metrics" = Vec<InputMetric>, Path, description = "Metrics list to work with"),
|
||||||
|
)
|
||||||
|
)]
|
||||||
pub async fn model_rest_handler(
|
pub async fn model_rest_handler(
|
||||||
State(config) : State<Config>,
|
State(config) : State<Config>,
|
||||||
Json(req) : Json<Vec<InputMetric>>,
|
Json(req) : Json<Vec<InputMetric>>,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ mod endpoints;
|
||||||
mod schemas;
|
mod schemas;
|
||||||
mod models;
|
mod models;
|
||||||
mod setup;
|
mod setup;
|
||||||
|
mod api_docs;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tracing::{debug, info, trace};
|
use tracing::{debug, info, trace};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct InputMetric {
|
pub struct InputMetric {
|
||||||
id : String,
|
id : String,
|
||||||
name : String,
|
name : String,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue