|
|
|
@ -2,8 +2,7 @@ use std::fs::File;
|
|
|
|
|
use std::io::{BufReader, Read};
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
use actix_web::http::header;
|
|
|
|
|
use actix_web::{get, HttpRequest, HttpResponse};
|
|
|
|
|
use actix_web::{get, HttpResponse};
|
|
|
|
|
use actix_web::web::{Data, Path};
|
|
|
|
|
|
|
|
|
|
use handlebars::Handlebars;
|
|
|
|
@ -13,13 +12,11 @@ use serde_json::json;
|
|
|
|
|
use crate::Result;
|
|
|
|
|
|
|
|
|
|
#[get("/+{id}")]
|
|
|
|
|
pub async fn get(req: HttpRequest, id: Path<String>, hb: Data<Handlebars<'_>>) -> Result<HttpResponse> {
|
|
|
|
|
println!("HIHIHI");
|
|
|
|
|
pub async fn get(id: Path<String>, hb: Data<Handlebars<'_>>) -> Result<HttpResponse> {
|
|
|
|
|
let mut path = PathBuf::from("replays");
|
|
|
|
|
let id: String = id.into_inner();
|
|
|
|
|
path.push(&id);
|
|
|
|
|
let file: File = File::open(&path)?;
|
|
|
|
|
info!("loaded file: {:?}", path);
|
|
|
|
|
let mut buffer = BufReader::new(file);
|
|
|
|
|
let mut file_contents = String::new();
|
|
|
|
|
buffer.read_to_string(&mut file_contents)?;
|
|
|
|
|