Fix some parts

pull/30/head
Miroito 3 years ago
parent 9a297f5b38
commit 6b68bce011

@ -56,7 +56,6 @@ pub struct AppState {
#[tokio::main] #[tokio::main]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> { pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
// logger::init_log()?;
tracing_subscriber::registry() tracing_subscriber::registry()
.with( .with(
tracing_subscriber::EnvFilter::try_from_default_env() tracing_subscriber::EnvFilter::try_from_default_env()
@ -129,15 +128,9 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
), ),
) )
.layer( .layer(
// see https://docs.rs/tower-http/latest/tower_http/cors/index.html
// for more details
//
// pay attention that for some request types like posting content-type: application/json
// it is required to add ".allow_headers([http::header::CONTENT_TYPE])"
// or see this issue https://github.com/tokio-rs/axum/issues/849
CorsLayer::new() CorsLayer::new()
.allow_origin("*".parse::<HeaderValue>().unwrap()) .allow_origin("*".parse::<HeaderValue>().unwrap())
.allow_methods([Method::GET]), .allow_methods([Method::GET])
); );
// Run tasks // Run tasks

@ -33,7 +33,7 @@ pub async fn get_by_name(
let conn = state.db; let conn = state.db;
let res = company::Entity::find() let res = company::Entity::find()
.filter(company::Column::Name.contains(&name)) .filter(company::Column::Name.contains(&name))
.limit(limit.unwrap_or(10)) .limit(limit.unwrap_or(10).min(10))
.all(&conn) .all(&conn)
.await?; .await?;

Loading…
Cancel
Save