mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-02-23 10:48:32 +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},)*) => {
|
($({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)]
|
#[allow(dead_code)]
|
||||||
const _: () = {
|
const _: () = {
|
||||||
#[allow(dead_code)]
|
// First, verify that all fields in Settings are listed in the macro
|
||||||
const fn __verify_settings_exist() {
|
const fn __verify_settings_exist() {
|
||||||
let _: fn() = || {
|
// This pattern match will fail at compile time if any field is missing from the macro
|
||||||
let meilisearch_types::settings::Settings { $($attr: _,)* .. }:
|
// or if a field exists in the macro but not in Settings
|
||||||
meilisearch_types::settings::Settings<meilisearch_types::settings::Unchecked>;
|
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_export]
|
||||||
macro_rules! make_setting_route {
|
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 {
|
pub mod $attr {
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::{web, HttpRequest, HttpResponse, Resource};
|
use actix_web::{web, HttpRequest, HttpResponse, Resource};
|
||||||
@ -113,7 +122,7 @@ macro_rules! make_setting_route {
|
|||||||
Data<IndexScheduler>,
|
Data<IndexScheduler>,
|
||||||
>,
|
>,
|
||||||
index_uid: actix_web::web::Path<String>,
|
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,
|
req: HttpRequest,
|
||||||
opt: web::Data<Opt>,
|
opt: web::Data<Opt>,
|
||||||
analytics: web::Data<Analytics>,
|
analytics: web::Data<Analytics>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user