mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-02-22 18:28:37 +01:00
made changes to ensure its not allowing everything through
This commit is contained in:
parent
dddb51a9ca
commit
1fb96d3edb
@ -27,12 +27,21 @@ macro_rules! make_setting_routes {
|
||||
($({route: $route:literal, update_verb: $update_verb:ident, value_type: $type:ty, err_type: $err_ty:ty, attr: $attr:ident, camelcase_attr: $camelcase_attr:literal, analytics: $analytics:ident},)*) => {
|
||||
#[allow(dead_code)]
|
||||
const _: () = {
|
||||
#[allow(dead_code)]
|
||||
// First, verify that all fields in Settings are listed in the macro
|
||||
const fn __verify_settings_exist() {
|
||||
let _: fn() = || {
|
||||
let meilisearch_types::settings::Settings { $($attr: _,)* .. }:
|
||||
meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>;
|
||||
// This pattern match will fail at compile time if any field is missing from the macro
|
||||
// or if a field exists in the macro but not in Settings
|
||||
let _: fn(meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>) = |s| {
|
||||
match s {
|
||||
meilisearch_types::settings::Settings {
|
||||
$($attr: _,)*
|
||||
_kind: _,
|
||||
} => {}
|
||||
}
|
||||
};
|
||||
|
||||
// if any field is missing or has the wrong type
|
||||
let _: fn(meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>) = |_| {};
|
||||
}
|
||||
};
|
||||
|
||||
@ -56,7 +65,7 @@ macro_rules! make_setting_routes {
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! make_setting_route {
|
||||
($route:literal, $update_verb:ident, $type:ty, $err_ty:ty, $attr:ident, $camelcase_attr:literal, $analytics:ident) => {
|
||||
($route:literal, $update_verb:ident, $type:ty, $err_type:ty, $attr:ident, $camelcase_attr:literal, $analytics:ident) => {
|
||||
pub mod $attr {
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{web, HttpRequest, HttpResponse, Resource};
|
||||
@ -113,7 +122,7 @@ macro_rules! make_setting_route {
|
||||
Data<IndexScheduler>,
|
||||
>,
|
||||
index_uid: actix_web::web::Path<String>,
|
||||
body: deserr::actix_web::AwebJson<Option<$type>, $err_ty>,
|
||||
body: deserr::actix_web::AwebJson<Option<$type>, $err_type>,
|
||||
req: HttpRequest,
|
||||
opt: web::Data<Opt>,
|
||||
analytics: web::Data<Analytics>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user