2019-10-31 15:00:36 +01:00
|
|
|
use crate::data::Data;
|
|
|
|
|
|
|
|
pub mod document;
|
|
|
|
pub mod health;
|
|
|
|
pub mod index;
|
|
|
|
pub mod key;
|
|
|
|
pub mod search;
|
|
|
|
pub mod setting;
|
|
|
|
pub mod stats;
|
|
|
|
pub mod stop_words;
|
|
|
|
pub mod synonym;
|
|
|
|
|
|
|
|
pub fn load_routes(app: &mut tide::App<Data>) {
|
|
|
|
app.at("").nest(|router| {
|
|
|
|
router.at("/indexes").nest(|router| {
|
2019-11-20 11:24:08 +01:00
|
|
|
router
|
|
|
|
.at("/")
|
2019-11-19 16:07:24 +01:00
|
|
|
.get(index::list_indexes)
|
|
|
|
.post(index::create_index);
|
2019-10-31 15:00:36 +01:00
|
|
|
|
|
|
|
router.at("/search").post(search::search_multi_index);
|
|
|
|
|
|
|
|
router.at("/:index").nest(|router| {
|
|
|
|
router.at("/search").get(search::search_with_url_query);
|
|
|
|
|
|
|
|
router.at("/updates").nest(|router| {
|
|
|
|
router.at("/").get(index::get_all_updates_status);
|
|
|
|
|
|
|
|
router.at("/:update_id").get(index::get_update_status);
|
|
|
|
});
|
|
|
|
|
|
|
|
router
|
|
|
|
.at("/")
|
2019-11-19 17:40:11 +01:00
|
|
|
.get(index::get_index)
|
2019-11-20 15:00:06 +01:00
|
|
|
.put(index::update_index)
|
2019-10-31 15:00:36 +01:00
|
|
|
.delete(index::delete_index);
|
|
|
|
|
2019-11-19 17:40:11 +01:00
|
|
|
router
|
|
|
|
.at("/schema")
|
|
|
|
.get(index::get_index_schema)
|
|
|
|
.put(index::update_schema);
|
|
|
|
|
2019-10-31 15:00:36 +01:00
|
|
|
router.at("/documents").nest(|router| {
|
|
|
|
router
|
|
|
|
.at("/")
|
2019-11-20 14:18:21 +01:00
|
|
|
.get(document::get_all_documents)
|
2019-11-06 11:18:36 +01:00
|
|
|
.post(document::add_or_replace_multiple_documents)
|
|
|
|
.put(document::add_or_update_multiple_documents)
|
2019-10-31 15:00:36 +01:00
|
|
|
.delete(document::clear_all_documents);
|
|
|
|
|
|
|
|
router.at("/:identifier").nest(|router| {
|
|
|
|
router
|
|
|
|
.at("/")
|
|
|
|
.get(document::get_document)
|
|
|
|
.delete(document::delete_document);
|
|
|
|
});
|
|
|
|
|
|
|
|
router
|
|
|
|
.at("/delete")
|
|
|
|
.post(document::delete_multiple_documents);
|
|
|
|
});
|
|
|
|
|
|
|
|
router.at("/synonym").nest(|router| {
|
2019-11-20 14:12:12 +01:00
|
|
|
router
|
|
|
|
.at("/")
|
|
|
|
.get(synonym::list)
|
|
|
|
.post(synonym::create)
|
|
|
|
.delete(synonym::clear);
|
2019-10-31 15:00:36 +01:00
|
|
|
|
|
|
|
router
|
|
|
|
.at("/:synonym")
|
|
|
|
.get(synonym::get)
|
|
|
|
.put(synonym::update)
|
|
|
|
.delete(synonym::delete);
|
|
|
|
|
|
|
|
router.at("/batch").post(synonym::batch_write);
|
|
|
|
});
|
|
|
|
|
|
|
|
router.at("/stop-words").nest(|router| {
|
|
|
|
router
|
|
|
|
.at("/")
|
|
|
|
.get(stop_words::list)
|
2019-11-20 13:56:43 +01:00
|
|
|
.patch(stop_words::add)
|
2019-10-31 15:00:36 +01:00
|
|
|
.delete(stop_words::delete);
|
|
|
|
});
|
|
|
|
|
|
|
|
router
|
|
|
|
.at("/settings")
|
|
|
|
.get(setting::get)
|
|
|
|
.post(setting::update);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
router.at("/keys").nest(|router| {
|
|
|
|
router.at("/").get(key::list).post(key::create);
|
|
|
|
|
|
|
|
router
|
|
|
|
.at("/:key")
|
|
|
|
.get(key::get)
|
|
|
|
.put(key::update)
|
|
|
|
.delete(key::delete);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Private
|
|
|
|
app.at("").nest(|router| {
|
|
|
|
router
|
|
|
|
.at("/health")
|
|
|
|
.get(health::get_health)
|
|
|
|
.post(health::set_healthy)
|
|
|
|
.put(health::change_healthyness)
|
|
|
|
.delete(health::set_unhealthy);
|
|
|
|
|
|
|
|
router.at("/stats").get(stats::get_stats);
|
|
|
|
router.at("/stats/:index").get(stats::index_stat);
|
|
|
|
router.at("/version").get(stats::get_version);
|
|
|
|
router.at("/sys-info").get(stats::get_sys_info);
|
|
|
|
router
|
|
|
|
.at("/sys-info/pretty")
|
|
|
|
.get(stats::get_sys_info_pretty);
|
|
|
|
});
|
|
|
|
}
|