Skip to content

Commit 93efa64

Browse files
committed
Serve ansi_up javascript library our-selves
1 parent 35254b5 commit 93efa64

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/gha_logs.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use crate::github;
22
use crate::handlers::Context;
33
use anyhow::Context as _;
4-
use hyper::header::{CONTENT_SECURITY_POLICY, CONTENT_TYPE};
4+
use hyper::header::{CACHE_CONTROL, CONTENT_SECURITY_POLICY, CONTENT_TYPE};
55
use hyper::{Body, Response, StatusCode};
66
use std::collections::VecDeque;
77
use std::str::FromStr;
88
use std::sync::Arc;
99
use uuid::Uuid;
1010

11-
const ANSI_UP_URL: &str = "https://cdn.jsdelivr.net/npm/[email protected]/+esm";
11+
pub const ANSI_UP_URL: &str = "/gha_logs/[email protected].min.js";
1212
const MAX_CACHE_CAPACITY_BYTES: u64 = 50 * 1024 * 1024; // 50 Mb
1313

1414
#[derive(Default)]
@@ -172,3 +172,14 @@ async fn process_logs(
172172
)
173173
.body(Body::from(html))?);
174174
}
175+
176+
pub fn ansi_up_min_js() -> anyhow::Result<Response<Body>, hyper::Error> {
177+
const ANSI_UP_MIN_JS: &str = include_str!("gha_logs/[email protected]");
178+
179+
Ok(Response::builder()
180+
.status(StatusCode::OK)
181+
.header(CACHE_CONTROL, "public, max-age=15552000, immutable")
182+
.header(CONTENT_TYPE, "text/javascript; charset=utf-8")
183+
.body(Body::from(ANSI_UP_MIN_JS))
184+
.unwrap())
185+
}

src/gha_logs/[email protected]

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ async fn serve_req(
6565
}
6666
}
6767

68+
if req.uri.path() == triagebot::gha_logs::ANSI_UP_URL {
69+
return triagebot::gha_logs::ansi_up_min_js();
70+
}
6871
if req.uri.path() == "/agenda" {
6972
return Ok(Response::builder()
7073
.status(StatusCode::OK)

0 commit comments

Comments
 (0)