route get / requests to sync docs (#1182)

* route get / requests to sync docs
This commit is contained in:
Tif Tran 2021-12-06 10:08:52 -08:00 committed by GitHub
parent 04cf2344d5
commit 94aece75b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,8 @@ use std::{sync::Arc, time::Duration};
use actix_cors::Cors;
use actix_web::{
dev, http::StatusCode, middleware::errhandlers::ErrorHandlers, web, App, HttpRequest,
HttpResponse, HttpServer,
dev, http::header::LOCATION, http::StatusCode, middleware::errhandlers::ErrorHandlers, web,
App, HttpRequest, HttpResponse, HttpServer,
};
use cadence::StatsdClient;
use tokio::sync::RwLock;
@ -19,6 +19,8 @@ use crate::web::{handlers, middleware};
pub const BSO_ID_REGEX: &str = r"[ -~]{1,64}";
pub const COLLECTION_ID_REGEX: &str = r"[a-zA-Z0-9._-]{1,32}";
pub const SYNC_DOCS_URL: &str =
"https://mozilla-services.readthedocs.io/en/latest/storage/apis-1.5.html";
const MYSQL_UID_REGEX: &str = r"[0-9]{1,10}";
const SYNC_VERSION_PATH: &str = "1.5";
@ -162,6 +164,11 @@ macro_rules! build_app {
})),
)
.service(web::resource("/__error__").route(web::get().to(handlers::test_error)))
.service(web::resource("/").route(web::get().to(|_: HttpRequest| {
HttpResponse::Found()
.header(LOCATION, SYNC_DOCS_URL)
.finish()
})))
};
}
@ -211,6 +218,11 @@ macro_rules! build_app_without_syncstorage {
.body(include_str!("../../version.json"))
})),
)
.service(web::resource("/").route(web::get().to(|_: HttpRequest| {
HttpResponse::Found()
.header(LOCATION, SYNC_DOCS_URL)
.finish()
})))
};
}