[O] CORS allow

This commit is contained in:
Azalea Gui
2023-02-23 15:10:38 -05:00
parent bc975a1d29
commit d4c36be288
+3 -2
View File
@@ -1,5 +1,5 @@
use std::path::PathBuf;
use hyper::{Body, http, Response, StatusCode};
use hyper::{Body, header, http, Response, StatusCode};
pub trait StringExt {
fn resp(&self, status: u16) -> http::Result<Response<Body>>;
@@ -7,7 +7,8 @@ pub trait StringExt {
impl StringExt for String {
fn resp(&self, status: u16) -> http::Result<Response<Body>> {
Response::builder().status(StatusCode::from_u16(status).unwrap()).body(Body::from(self.to_owned()))
Response::builder().header(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.status(StatusCode::from_u16(status).unwrap()).body(Body::from(self.to_owned()))
}
}