Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add favicon #351

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl Server {
.route("/block/:hash", get(Self::block))
.route("/bounties", get(Self::bounties))
.route("/faq", get(Self::faq))
.route("/favicon.ico", get(Self::favicon))
.route("/height", get(Self::height))
.route("/ordinal/:ordinal", get(Self::ordinal))
.route("/output/:output", get(Self::output))
Expand Down Expand Up @@ -329,6 +330,10 @@ impl Server {
)
}

async fn favicon() -> impl IntoResponse {
Self::static_asset(extract::Path("/favicon.png".to_string())).await
}

async fn static_asset(extract::Path(path): extract::Path<String>) -> impl IntoResponse {
match StaticAssets::get(if let Some(stripped) = path.strip_prefix('/') {
stripped
Expand Down
Binary file added static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,9 @@ fn bounties() {
r".*<title>Ordinal Bounties</title>.*<h1>Ordinal Bounties</h1>.*",
);
}

#[test]
fn favicon() {
let mut state = State::new();
state.request_expected("favicon.ico", 200, Expected::Ignore);
}