add favicon

This commit is contained in:
Franz Dietrich 2023-06-15 10:48:42 +02:00
parent ba15f8ed0c
commit 8121dbcb7c
2 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use axum::{
routing::{get, post}, routing::{get, post},
Form, Json, Router, Form, Json, Router,
}; };
use hyper::{header, HeaderMap};
use serde::Deserialize; use serde::Deserialize;
use sqlx::{query, SqlitePool}; use sqlx::{query, SqlitePool};
use std::{env, net::SocketAddr}; use std::{env, net::SocketAddr};
@ -35,6 +36,7 @@ async fn main() {
.nest_service("/static", ServeDir::new(static_path)) .nest_service("/static", ServeDir::new(static_path))
.route("/", get(register_form)) .route("/", get(register_form))
.route("/register/", post(register)) .route("/register/", post(register))
.route("/favicon.ico", get(favicon))
.with_state(db_pool); .with_state(db_pool);
// run it // run it
@ -131,3 +133,11 @@ where
{ {
(StatusCode::INTERNAL_SERVER_ERROR, err.to_string()) (StatusCode::INTERNAL_SERVER_ERROR, err.to_string())
} }
async fn favicon() -> impl IntoResponse {
let mut headers = HeaderMap::new();
headers.insert(header::CONTENT_TYPE, "image/x-icon".parse().unwrap());
let bytes = include_bytes!("../static/favicon.ico");
(headers, bytes)
}

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB