allow all routes to also respond to HEAD requests
i've noticed that some services out there seem to issue HEAD requests to web sites as part of some sort of metadata fetching process about links contained in content that they are processing (e.g. Mastodon). currently we were just responding with 404's to these because actix does not respond to HEAD requests for any route unless you explicitly set up the request to respond that way (with the sole exception being the default route handler in actix which is invoked for any type of request)
This commit is contained in:
parent
2aba6152bd
commit
746f92f52b
|
@ -16,26 +16,26 @@ fn not_found() -> HttpResponse {
|
|||
HttpResponse::NotFound().body("not found")
|
||||
}
|
||||
|
||||
#[actix_web::get("/")]
|
||||
#[actix_web::route("/", method = "GET", method = "HEAD")]
|
||||
async fn latest_posts(data: web::Data<site::SiteService>) -> impl Responder {
|
||||
log::debug!("GET / -> latest_posts()");
|
||||
data.serve_latest_post()
|
||||
}
|
||||
|
||||
#[actix_web::get("/tag/{tag}")]
|
||||
#[actix_web::route("/tag/{tag}", method = "GET", method = "HEAD")]
|
||||
async fn latest_posts_by_tag(path: web::Path<(String,)>, data: web::Data<site::SiteService>) -> impl Responder {
|
||||
let tag = path.into_inner().0;
|
||||
log::debug!("GET /tag/{0} -> latest_posts_by_tag(), tag = {0}", tag);
|
||||
data.serve_posts_by_tag(&tag)
|
||||
}
|
||||
|
||||
#[actix_web::get("/archive")]
|
||||
#[actix_web::route("/archive", method = "GET", method = "HEAD")]
|
||||
async fn posts_archive(data: web::Data<site::SiteService>) -> impl Responder {
|
||||
log::debug!("GET /archive -> posts_archive()");
|
||||
data.serve_posts_archive()
|
||||
}
|
||||
|
||||
#[actix_web::get("/rss")]
|
||||
#[actix_web::route("/rss", method = "GET", method = "HEAD")]
|
||||
async fn rss_feed(data: web::Data<site::SiteService>) -> impl Responder {
|
||||
log::debug!("GET /rss -> rss_feed()");
|
||||
data.serve_rss_feed()
|
||||
|
|
Loading…
Reference in a new issue