mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-23 19:15:31 +08:00
updated to fix macro error by creating one method to ensure all routes corresponding to fields adn another to ensure each field provided in settings has a corresponding route
This commit is contained in:
parent
0a0a5f84bf
commit
262b429a4c
@ -17,17 +17,37 @@ use crate::extractors::authentication::GuardedData;
|
|||||||
use crate::routes::{get_task_id, is_dry_run, SummarizedTaskView};
|
use crate::routes::{get_task_id, is_dry_run, SummarizedTaskView};
|
||||||
use crate::Opt;
|
use crate::Opt;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn verify_all_settings_fields<FH>(settings: Settings<FH>) {
|
||||||
|
match settings {
|
||||||
|
Settings {
|
||||||
|
filterable_attributes: _,
|
||||||
|
sortable_attributes: _,
|
||||||
|
displayed_attributes: _,
|
||||||
|
searchable_attributes: _,
|
||||||
|
distinct_attribute: _,
|
||||||
|
proximity_precision: _,
|
||||||
|
typo_tolerance: _,
|
||||||
|
faceting: _,
|
||||||
|
pagination: _,
|
||||||
|
stop_words: _,
|
||||||
|
synonyms: _,
|
||||||
|
embedders: _,
|
||||||
|
ranking_rules: _,
|
||||||
|
search_cutoff_ms: _,
|
||||||
|
localized_attributes: _,
|
||||||
|
dictionary: _,
|
||||||
|
separator_tokens: _,
|
||||||
|
non_separator_tokens: _,
|
||||||
|
..
|
||||||
|
} => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[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_ty:ty, $attr:ident, $camelcase_attr:literal, $analytics:ident) => {
|
||||||
#[allow(dead_code)]
|
|
||||||
|
|
||||||
pub fn verify_field_exists_for_$attr<FH>(settings: Settings<FH>) {
|
|
||||||
match settings {
|
|
||||||
Settings { $attr: _, .. } => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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};
|
||||||
@ -45,6 +65,19 @@ macro_rules! make_setting_route {
|
|||||||
use $crate::Opt;
|
use $crate::Opt;
|
||||||
use $crate::routes::{is_dry_run, get_task_id, SummarizedTaskView};
|
use $crate::routes::{is_dry_run, get_task_id, SummarizedTaskView};
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct VerifySettingExists<FH>(std::marker::PhantomData<FH>);
|
||||||
|
#[allow(dead_code)]
|
||||||
|
impl<FH> VerifySettingExists<FH> {
|
||||||
|
const VERIFY: () = {
|
||||||
|
match None::<Settings<FH>> {
|
||||||
|
Some(Settings { $attr: _, .. }) => (),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn delete(
|
pub async fn delete(
|
||||||
index_scheduler: GuardedData<
|
index_scheduler: GuardedData<
|
||||||
ActionPolicy<{ actions::SETTINGS_UPDATE }>,
|
ActionPolicy<{ actions::SETTINGS_UPDATE }>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user