mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
add middleware
This commit is contained in:
parent
6a1f73a304
commit
5fed155f15
13
Cargo.lock
generated
13
Cargo.lock
generated
@ -34,6 +34,18 @@ dependencies = [
|
||||
"trust-dns-resolver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-cors"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a6206917d5c0fdd79d81cec9ef02d3e802df4abf276d96241e1f595d971e002"
|
||||
dependencies = [
|
||||
"actix-service",
|
||||
"actix-web",
|
||||
"derive_more",
|
||||
"futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-files"
|
||||
version = "0.2.1"
|
||||
@ -1489,6 +1501,7 @@ dependencies = [
|
||||
name = "meilisearch-http"
|
||||
version = "0.10.1"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-files",
|
||||
"actix-http",
|
||||
"actix-rt",
|
||||
|
@ -45,6 +45,7 @@ actix-rt = "1"
|
||||
actix-web = "2"
|
||||
actix-http = "1"
|
||||
actix-files = "0.2.1"
|
||||
actix-cors = "0.2.0"
|
||||
tokio = { version = "0.2.0", features = ["macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{env, thread};
|
||||
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{web, App, HttpServer, middleware};
|
||||
use log::info;
|
||||
use main_error::MainError;
|
||||
use meilisearch_http::data::Data;
|
||||
@ -52,7 +52,14 @@ async fn main() -> Result<(), MainError> {
|
||||
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(Logger::default())
|
||||
.wrap(
|
||||
Cors::new()
|
||||
.send_wildcard()
|
||||
.allowed_header("x-meili-api-key")
|
||||
.finish()
|
||||
)
|
||||
.wrap(middleware::Logger::default())
|
||||
.wrap(middleware::Compress::default())
|
||||
.app_data(web::Data::new(data.clone()))
|
||||
.service(routes::load_html)
|
||||
.service(routes::load_css)
|
||||
|
Loading…
Reference in New Issue
Block a user