Move from json to csv for masterdata

This commit is contained in:
Ethan O'Brien
2026-05-02 00:33:30 -05:00
parent dc0a62aca4
commit 4f42e5029b
365 changed files with 106991 additions and 1311619 deletions

View File

@@ -1,8 +1,7 @@
use actix_web::{HttpResponse, HttpRequest, web, Responder};
use actix_web::http::header::ContentType;
use include_dir::{include_dir, Dir};
static MASTERDATA: Dir<'_> = include_dir!("src/router/masterdata/json/");
static MASTERDATA: Dir<'_> = include_dir!("src/router/masterdata/csv/");
pub fn routes(cfg: &mut web::ServiceConfig) {
cfg.service(
@@ -13,11 +12,10 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
async fn mst(req: HttpRequest) -> impl Responder {
let mst = req.match_info().get("MST").unwrap();
println!("Getting masterdata {}", mst);
if let Some(file) = MASTERDATA.get_file(format!("{mst}.json")) {
if let Some(file) = MASTERDATA.get_file(format!("{mst}.csv")) {
let body = file.contents();
return HttpResponse::Ok()
.insert_header(ContentType::json())
.insert_header(("content-type", "text/csv; charset=utf-8"))
.insert_header(("content-length", body.len()))
.body(body);
}