|
| 1 | +use actix_web::{delete, get, patch, post, put, web, HttpRequest, Responder}; |
| 2 | +use common::State; |
| 3 | +use redirect::redirect; |
| 4 | +use tracing::instrument; |
| 5 | + |
| 6 | +pub mod redirect; |
| 7 | + |
| 8 | +// https://kubernetes.io/docs/reference/using-api/api-concepts/#api-verbs |
| 9 | + |
| 10 | +/// Cluster redirect |
| 11 | +/// |
| 12 | +/// Redirect to the cluster if exists |
| 13 | +#[utoipa::path( |
| 14 | + tag = "clusters", |
| 15 | + responses( |
| 16 | + (status = 200, description = "ATM nothing real"), |
| 17 | + (status = 500, description = "Internal server error."), |
| 18 | + ) |
| 19 | +)] |
| 20 | +#[get("/{ns}/{cluster}/{path:.*}")] |
| 21 | +#[instrument(name = "get_redirect", skip(data))] |
| 22 | +pub async fn get_redirect(req: HttpRequest, data: web::Data<State>) -> impl Responder { |
| 23 | + redirect(req, data).await |
| 24 | +} |
| 25 | + |
| 26 | +/// Cluster redirect |
| 27 | +/// |
| 28 | +/// Redirect to the cluster if exists |
| 29 | +#[utoipa::path( |
| 30 | + tag = "clusters", |
| 31 | + responses( |
| 32 | + (status = 200, description = "ATM nothing real"), |
| 33 | + (status = 500, description = "Internal server error."), |
| 34 | + ) |
| 35 | +)] |
| 36 | +#[post("/{ns}/{cluster}/{path:.*}")] |
| 37 | +#[instrument(name = "post_redirect", skip(data))] |
| 38 | +pub async fn post_redirect(req: HttpRequest, data: web::Data<State>) -> impl Responder { |
| 39 | + redirect(req, data).await |
| 40 | +} |
| 41 | + |
| 42 | +/// Cluster redirect |
| 43 | +/// |
| 44 | +/// Redirect to the cluster if exists |
| 45 | +#[utoipa::path( |
| 46 | + tag = "clusters", |
| 47 | + responses( |
| 48 | + (status = 200, description = "ATM nothing real"), |
| 49 | + (status = 500, description = "Internal server error."), |
| 50 | + ) |
| 51 | +)] |
| 52 | +#[put("/{ns}/{cluster}/{path:.*}")] |
| 53 | +#[instrument(name = "put_redirect", skip(data))] |
| 54 | +pub async fn put_redirect(req: HttpRequest, data: web::Data<State>) -> impl Responder { |
| 55 | + redirect(req, data).await |
| 56 | +} |
| 57 | + |
| 58 | +/// Cluster redirect |
| 59 | +/// |
| 60 | +/// Redirect to the cluster if exists |
| 61 | +#[utoipa::path( |
| 62 | + tag = "clusters", |
| 63 | + responses( |
| 64 | + (status = 200, description = "ATM nothing real"), |
| 65 | + (status = 500, description = "Internal server error."), |
| 66 | + ) |
| 67 | +)] |
| 68 | +#[patch("/{ns}/{cluster}/{path:.*}")] |
| 69 | +#[instrument(name = "patch_redirect", skip(data))] |
| 70 | +pub async fn patch_redirect(req: HttpRequest, data: web::Data<State>) -> impl Responder { |
| 71 | + redirect(req, data).await |
| 72 | +} |
| 73 | + |
| 74 | +/// Cluster redirect |
| 75 | +/// |
| 76 | +/// Redirect to the cluster if exists |
| 77 | +#[utoipa::path( |
| 78 | + tag = "clusters", |
| 79 | + responses( |
| 80 | + (status = 200, description = "ATM nothing real"), |
| 81 | + (status = 500, description = "Internal server error."), |
| 82 | + ) |
| 83 | +)] |
| 84 | +#[delete("/{ns}/{cluster}/{path:.*}")] |
| 85 | +#[instrument(name = "delete_redirect", skip(data))] |
| 86 | +pub async fn delete_redirect(req: HttpRequest, data: web::Data<State>) -> impl Responder { |
| 87 | + redirect(req, data).await |
| 88 | +} |
0 commit comments