change route to service<resource>

This commit is contained in:
marin postma 2021-06-24 19:02:28 +02:00
parent 3b601f615a
commit 01b09c065b
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9
7 changed files with 30 additions and 30 deletions

View File

@ -90,13 +90,13 @@ pub fn dashboard(config: &mut web::ServiceConfig, enable_frontend: bool) {
}
config.service(scope);
} else {
config.route("/", web::get().to(routes::running));
config.service(web::resource("/").route(web::get().to(routes::running)));
}
}
#[cfg(not(feature = "mini-dashboard"))]
pub fn dashboard(config: &mut web::ServiceConfig, _enable_frontend: bool) {
config.route("/", web::get().to(routes::running));
config.service(web::resource("/").route(web::get().to(routes::running)));
}
#[macro_export]

View File

@ -38,21 +38,21 @@ struct DocumentParam {
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(
web::resource("/indexes/{index_uid}/documents")
web::scope("/indexes/{index_uid}/documents")
.service(
web::resource("")
.route(web::get().to(get_all_documents))
.route(web::post().guard(guard_json).to(add_documents))
.route(web::put().guard(guard_json).to(update_documents))
.route(web::delete().to(clear_all_documents)),
)
// this route needs to be before the /documents/{document_id} to match properly
.route(
"/indexes/{index_uid}/documents/delete-batch",
web::post().to(delete_documents),
)
.service(web::resource("/delete-batch").route(web::post().to(delete_documents)))
.service(
web::resource("/indexes/{index_uid}/documents/{document_id}")
web::resource("/{document_id}")
.route(web::get().to(get_document))
.route(web::delete().to(delete_document)),
),
);
}

View File

@ -7,8 +7,8 @@ use crate::extractors::authentication::{policies::*, GuardedData};
use crate::Data;
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.route("/dumps", web::post().to(create_dump))
.route("/dumps/{dump_uid}/status", web::get().to(get_dump_status));
cfg.service(web::resource("/dumps").route(web::post().to(create_dump)))
.service(web::resource("/dumps/{dump_uid}/status").route(web::get().to(get_dump_status)));
}
async fn create_dump(data: GuardedData<Private, Data>) -> Result<HttpResponse, ResponseError> {

View File

@ -3,7 +3,7 @@ use actix_web::{web, HttpResponse};
use crate::error::ResponseError;
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.route("/health", web::get().to(get_health));
cfg.service(web::resource("/health").route(web::get().to(get_health)));
}
async fn get_health() -> Result<HttpResponse, ResponseError> {

View File

@ -20,13 +20,13 @@ pub fn services(cfg: &mut web::ServiceConfig) {
.route(web::put().to(update_index))
.route(web::delete().to(delete_index)),
)
.route(
"/indexes/{index_uid}/updates",
web::get().to(get_all_updates_status),
.service(
web::resource("/indexes/{index_uid}/updates")
.route(web::get().to(get_all_updates_status))
)
.route(
"/indexes/{index_uid}/updates/{update_id}",
web::get().to(get_update_status),
.service(
web::resource("/indexes/{index_uid}/updates/{update_id}")
.route(web::get().to(get_update_status))
);
}

View File

@ -5,7 +5,7 @@ use crate::extractors::authentication::{policies::*, GuardedData};
use crate::Data;
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.route("/keys", web::get().to(list));
cfg.service(web::resource("/keys").route(web::get().to(list)));
}
#[derive(Serialize)]

View File

@ -8,9 +8,9 @@ use crate::routes::IndexParam;
use crate::Data;
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.route("/indexes/{index_uid}/stats", web::get().to(get_index_stats))
.route("/stats", web::get().to(get_stats))
.route("/version", web::get().to(get_version));
cfg.service(web::resource("/indexes/{index_uid}/stats").route(web::get().to(get_index_stats)))
.service(web::resource("/stats").route(web::get().to(get_stats)))
.service(web::resource("/version").route(web::get().to(get_version)));
}
async fn get_index_stats(