flattening code
This commit is contained in:
parent
12ce5a2c5a
commit
ef5b7a13f9
@ -45,15 +45,17 @@ const SHUTDOWN_ERR: u16 = 2;
|
||||
async fn route_dispatcher(pool: &Pool, resp: &mut Response<Body>, meth: &Method, path: &str, params: serde_json::Value) {
|
||||
// At some point we should have some way of hiding this obnoxious complexity
|
||||
use routes::resolve_dynamic_route;
|
||||
const GET: &Method = &Method::GET;
|
||||
const POST: &Method = &Method::POST;
|
||||
match (meth, path) {
|
||||
/* INVITES */
|
||||
(&Method::GET, routes::INVITE_CREATE) => invites::create(pool, resp, params).await,
|
||||
(GET, routes::INVITE_CREATE) => invites::create(pool, resp, params).await,
|
||||
/* CHANNELS */
|
||||
(&Method::GET, routes::CHANNELS_LIST) => channels::list_channels(pool, resp).await,
|
||||
(&Method::POST, routes::CHANNELS_CREATE) => channels::create_channel(pool, resp, params).await,
|
||||
(&Method::POST, routes::CHANNELS_DELETE) => channels::delete_channel(pool, resp, params).await,
|
||||
(GET, routes::CHANNELS_LIST) => channels::list_channels(pool, resp).await,
|
||||
(POST, routes::CHANNELS_CREATE) => channels::create_channel(pool, resp, params).await,
|
||||
(POST, routes::CHANNELS_DELETE) => channels::delete_channel(pool, resp, params).await,
|
||||
/* MESSAGING */
|
||||
(&Method::POST, routes::MESSAGE_SEND) => messages::send_message(pool, resp, params).await,
|
||||
(POST, routes::MESSAGE_SEND) => messages::send_message(pool, resp, params).await,
|
||||
_ => {
|
||||
// We attempt dynamic routes as fallback for a few reasons
|
||||
// 1. theres less of these than there are the static routes
|
||||
|
Loading…
Reference in New Issue
Block a user