mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 16:05:42 +00:00
send license and uid
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use crate::db::ApiAuthed;
|
||||
use axum::{body::Bytes, response::IntoResponse, routing::post, Router};
|
||||
use crate::db::DB;
|
||||
use axum::{body::Bytes, extract::Extension, response::IntoResponse, routing::post, Router};
|
||||
use http::{HeaderMap, StatusCode};
|
||||
use reqwest::Client;
|
||||
use tracing::{error, info, warn};
|
||||
use windmill_common::ee::WINDMILL_CUSTOMER_SERVICE_BASE_URL;
|
||||
use windmill_common::error::{to_anyhow, Error, Result};
|
||||
use tracing::error;
|
||||
use windmill_common::ee::{LICENSE_KEY, WINDMILL_CUSTOMER_SERVICE_BASE_URL};
|
||||
use windmill_common::utils::get_uid;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref HTTP_CLIENT: Client = reqwest::ClientBuilder::new()
|
||||
@@ -18,11 +18,13 @@ pub fn global_service() -> Router {
|
||||
}
|
||||
|
||||
pub async fn send_inkeep_request(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
headers: HeaderMap,
|
||||
body: Bytes,
|
||||
) -> impl IntoResponse {
|
||||
let request_url = format!("{}/inkeep", WINDMILL_CUSTOMER_SERVICE_BASE_URL.as_str());
|
||||
let license_key = LICENSE_KEY.read().await.clone();
|
||||
let uid = get_uid(&db).await.unwrap();
|
||||
|
||||
// Ensure Content-Type is set to application/json
|
||||
let mut forwarded_headers = headers.clone();
|
||||
@@ -30,7 +32,11 @@ pub async fn send_inkeep_request(
|
||||
http::header::CONTENT_TYPE,
|
||||
"application/json".parse().unwrap(),
|
||||
);
|
||||
forwarded_headers.insert("X-Uid", "test".parse().unwrap());
|
||||
forwarded_headers.insert(
|
||||
http::header::AUTHORIZATION,
|
||||
format!("Bearer {}", license_key).parse().unwrap(),
|
||||
);
|
||||
forwarded_headers.insert("X-Uid", uid.parse().unwrap());
|
||||
|
||||
match HTTP_CLIENT
|
||||
.post(&request_url)
|
||||
@@ -52,7 +58,7 @@ pub async fn send_inkeep_request(
|
||||
(status, response_headers, response_body)
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to read response body: {}", e);
|
||||
tracing::error!("Failed to read response body: {}", e);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
HeaderMap::new(),
|
||||
@@ -62,7 +68,7 @@ pub async fn send_inkeep_request(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to send request to inkeep service: {}", e);
|
||||
tracing::error!("Failed to send request to inkeep service: {}", e);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
HeaderMap::new(),
|
||||
|
||||
Reference in New Issue
Block a user