mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-06-19 15:52:08 +00:00
token.to_str() returns result
This commit is contained in:
parent
c5a982de82
commit
169c8c2cf5
@ -349,12 +349,6 @@ Options:
|
|||||||
--cors-allow-origin <CORS_ALLOW_ORIGIN>
|
--cors-allow-origin <CORS_ALLOW_ORIGIN>
|
||||||
[env: CORS_ALLOW_ORIGIN=]
|
[env: CORS_ALLOW_ORIGIN=]
|
||||||
|
|
||||||
```
|
|
||||||
## API_KEY
|
|
||||||
```shell
|
|
||||||
--api-key <API_KEY>
|
|
||||||
[env: API_KEY=]
|
|
||||||
|
|
||||||
```
|
```
|
||||||
## WATERMARK_GAMMA
|
## WATERMARK_GAMMA
|
||||||
```shell
|
```shell
|
||||||
@ -430,6 +424,22 @@ Options:
|
|||||||
|
|
||||||
[env: LORA_ADAPTERS=]
|
[env: LORA_ADAPTERS=]
|
||||||
|
|
||||||
|
```
|
||||||
|
## DISABLE_USAGE_STATS
|
||||||
|
```shell
|
||||||
|
--disable-usage-stats
|
||||||
|
Disable sending of all usage statistics
|
||||||
|
|
||||||
|
[env: DISABLE_USAGE_STATS=]
|
||||||
|
|
||||||
|
```
|
||||||
|
## DISABLE_CRASH_REPORTS
|
||||||
|
```shell
|
||||||
|
--disable-crash-reports
|
||||||
|
Disable sending of crash reports, but allow anonymous usage statistics
|
||||||
|
|
||||||
|
[env: DISABLE_CRASH_REPORTS=]
|
||||||
|
|
||||||
```
|
```
|
||||||
## HELP
|
## HELP
|
||||||
```shell
|
```shell
|
||||||
|
@ -1249,7 +1249,7 @@ fn spawn_webserver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OpenTelemetry
|
// OpenTelemetry
|
||||||
if let Some(api_key) = args.api_key{
|
if let Some(api_key) = args.api_key {
|
||||||
router_args.push("--api-key".to_string());
|
router_args.push("--api-key".to_string());
|
||||||
router_args.push(api_key);
|
router_args.push(api_key);
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ use axum::response::{IntoResponse, Response};
|
|||||||
use axum::routing::{get, post};
|
use axum::routing::{get, post};
|
||||||
use axum::{http, Json, Router};
|
use axum::{http, Json, Router};
|
||||||
use axum_tracing_opentelemetry::middleware::OtelAxumLayer;
|
use axum_tracing_opentelemetry::middleware::OtelAxumLayer;
|
||||||
use http::header::AUTHORIZATION;
|
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use futures::stream::{FuturesOrdered, FuturesUnordered};
|
use futures::stream::{FuturesOrdered, FuturesUnordered};
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
|
use http::header::AUTHORIZATION;
|
||||||
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
|
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
@ -1815,10 +1815,13 @@ pub async fn run(
|
|||||||
request: axum::extract::Request,
|
request: axum::extract::Request,
|
||||||
next: axum::middleware::Next| async move {
|
next: axum::middleware::Next| async move {
|
||||||
match headers.get(AUTHORIZATION) {
|
match headers.get(AUTHORIZATION) {
|
||||||
Some(token) if token.to_str().to_lowercase() == api_key.to_lowercase() => {
|
Some(token) => match token.to_str() {
|
||||||
let response = next.run(request).await;
|
Ok(token_str) if token_str.to_lowercase() == api_key.to_lowercase() => {
|
||||||
Ok(response)
|
let response = next.run(request).await;
|
||||||
}
|
Ok(response)
|
||||||
|
}
|
||||||
|
_ => Err(StatusCode::UNAUTHORIZED),
|
||||||
|
},
|
||||||
_ => Err(StatusCode::UNAUTHORIZED),
|
_ => Err(StatusCode::UNAUTHORIZED),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user