explicitly set content-type to text/html; charset=utf-8
This commit is contained in:
parent
8cdd216b39
commit
9cf01f5991
2 changed files with 26 additions and 19 deletions
|
@ -4,7 +4,7 @@ use crate::config::{read_config, Route, RouteGroup};
|
||||||
use actix_web::{middleware::Logger, App, HttpServer};
|
use actix_web::{middleware::Logger, App, HttpServer};
|
||||||
use clap::{crate_authors, crate_version, load_yaml, App as ClapApp};
|
use clap::{crate_authors, crate_version, load_yaml, App as ClapApp};
|
||||||
use error::BunBunError;
|
use error::BunBunError;
|
||||||
use handlebars::{Handlebars};
|
use handlebars::Handlebars;
|
||||||
use hotwatch::{Event, Hotwatch};
|
use hotwatch::{Event, Hotwatch};
|
||||||
use log::{debug, info, trace, warn};
|
use log::{debug, info, trace, warn};
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
@ -118,7 +118,9 @@ fn cache_routes(groups: &[RouteGroup]) -> HashMap<String, Route> {
|
||||||
fn compile_templates() -> Handlebars {
|
fn compile_templates() -> Handlebars {
|
||||||
let mut handlebars = Handlebars::new();
|
let mut handlebars = Handlebars::new();
|
||||||
handlebars.set_strict_mode(true);
|
handlebars.set_strict_mode(true);
|
||||||
handlebars.register_partial("bunbun_version", env!("CARGO_PKG_VERSION")).unwrap();
|
handlebars
|
||||||
|
.register_partial("bunbun_version", env!("CARGO_PKG_VERSION"))
|
||||||
|
.unwrap();
|
||||||
macro_rules! register_template {
|
macro_rules! register_template {
|
||||||
[ $( $template:expr ),* ] => {
|
[ $( $template:expr ),* ] => {
|
||||||
$(
|
$(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{template_args, BunBunError, Route, State};
|
use crate::{template_args, BunBunError, Route, State};
|
||||||
|
use actix_web::http::header::ContentType;
|
||||||
use actix_web::web::{Data, Query};
|
use actix_web::web::{Data, Query};
|
||||||
use actix_web::{get, http::header};
|
use actix_web::{get, http::header};
|
||||||
use actix_web::{HttpRequest, HttpResponse, Responder};
|
use actix_web::{HttpRequest, HttpResponse, Responder};
|
||||||
|
@ -26,7 +27,9 @@ type StateData = Data<Arc<RwLock<State>>>;
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub async fn index(data: StateData, req: HttpRequest) -> impl Responder {
|
pub async fn index(data: StateData, req: HttpRequest) -> impl Responder {
|
||||||
let data = data.read().unwrap();
|
let data = data.read().unwrap();
|
||||||
HttpResponse::Ok().body(
|
HttpResponse::Ok()
|
||||||
|
.set_header(header::CONTENT_TYPE, "text/html; charset=utf-8")
|
||||||
|
.body(
|
||||||
req
|
req
|
||||||
.app_data::<Handlebars>()
|
.app_data::<Handlebars>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -61,7 +64,9 @@ pub async fn opensearch(data: StateData, req: HttpRequest) -> impl Responder {
|
||||||
#[get("/ls")]
|
#[get("/ls")]
|
||||||
pub async fn list(data: StateData, req: HttpRequest) -> impl Responder {
|
pub async fn list(data: StateData, req: HttpRequest) -> impl Responder {
|
||||||
let data = data.read().unwrap();
|
let data = data.read().unwrap();
|
||||||
HttpResponse::Ok().body(
|
HttpResponse::Ok()
|
||||||
|
.set_header(header::CONTENT_TYPE, "text/html; charset=utf-8")
|
||||||
|
.body(
|
||||||
req
|
req
|
||||||
.app_data::<Handlebars>()
|
.app_data::<Handlebars>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Reference in a new issue