new: Show version number

This commit is contained in:
SinTan1729
2024-02-10 19:41:50 -06:00
parent 0227c5f783
commit 95a8263797
3 changed files with 26 additions and 1 deletions

View File

@@ -19,6 +19,9 @@ struct AppState {
db: Connection,
}
// Store the version number
const VERSION: &str = env!("CARGO_PKG_VERSION");
// Define the routes
// Add new links
@@ -57,6 +60,12 @@ async fn siteurl(session: Session) -> HttpResponse {
}
}
// Get the version number
#[get("/api/version")]
async fn version() -> HttpResponse {
HttpResponse::Ok().body(VERSION)
}
// 404 error page
async fn error404() -> impl Responder {
NamedFile::open_async("./resources/static/404.html")
@@ -141,6 +150,7 @@ async fn main() -> std::io::Result<()> {
.service(link_handler)
.service(getall)
.service(siteurl)
.service(version)
.service(add_link)
.service(delete_link)
.service(login)