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 clap::{crate_authors, crate_version, load_yaml, App as ClapApp};
|
||||
use error::BunBunError;
|
||||
use handlebars::{Handlebars};
|
||||
use handlebars::Handlebars;
|
||||
use hotwatch::{Event, Hotwatch};
|
||||
use log::{debug, info, trace, warn};
|
||||
use std::cmp::min;
|
||||
|
@ -118,7 +118,9 @@ fn cache_routes(groups: &[RouteGroup]) -> HashMap<String, Route> {
|
|||
fn compile_templates() -> Handlebars {
|
||||
let mut handlebars = Handlebars::new();
|
||||
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 {
|
||||
[ $( $template:expr ),* ] => {
|
||||
$(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{template_args, BunBunError, Route, State};
|
||||
use actix_web::http::header::ContentType;
|
||||
use actix_web::web::{Data, Query};
|
||||
use actix_web::{get, http::header};
|
||||
use actix_web::{HttpRequest, HttpResponse, Responder};
|
||||
|
@ -26,7 +27,9 @@ type StateData = Data<Arc<RwLock<State>>>;
|
|||
#[get("/")]
|
||||
pub async fn index(data: StateData, req: HttpRequest) -> impl Responder {
|
||||
let data = data.read().unwrap();
|
||||
HttpResponse::Ok().body(
|
||||
HttpResponse::Ok()
|
||||
.set_header(header::CONTENT_TYPE, "text/html; charset=utf-8")
|
||||
.body(
|
||||
req
|
||||
.app_data::<Handlebars>()
|
||||
.unwrap()
|
||||
|
@ -61,7 +64,9 @@ pub async fn opensearch(data: StateData, req: HttpRequest) -> impl Responder {
|
|||
#[get("/ls")]
|
||||
pub async fn list(data: StateData, req: HttpRequest) -> impl Responder {
|
||||
let data = data.read().unwrap();
|
||||
HttpResponse::Ok().body(
|
||||
HttpResponse::Ok()
|
||||
.set_header(header::CONTENT_TYPE, "text/html; charset=utf-8")
|
||||
.body(
|
||||
req
|
||||
.app_data::<Handlebars>()
|
||||
.unwrap()
|
||||
|
|
Loading…
Reference in a new issue