use warp::Filter;
use super::handlers;
pub fn comments() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
index_page()
.or( show_few_comments() )
.or( show_comments_for_session_id() )
.or( show_comments_for() )
.or( add_comment() )
.or( update_comment_status() )
.or( update_comment_msg() )
.or( trash_comment() )
.or( get_static_file() )
.or( add_reply() )
.or( get_image() )
.or( get_icon() )
.or( update_reply_msg() )
.or( trash_reply() )
.or( upvote() )
.or( downvote() )
}
pub fn index_page() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::get()
.and( warp::path::end() )
.and_then( handlers::index )
}
pub fn show_few_comments() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comments")
.and(warp::get())
.and_then(handlers::show_few_comments)
}
pub fn show_comments_for_session_id() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comments"/ "session_id" / String)
.and(warp::get())
.and_then(handlers::show_comments_for_session_id)
}
pub fn show_comments_for() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comments" / usize)
.and(warp::get())
.and_then(handlers::show_comments_for)
}
pub fn add_comment() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comments")
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::add_comment)
}
pub fn update_comment_status() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comment" / String )
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::update_comment_status)
}
pub fn update_comment_msg() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comment_message")
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::update_comment_msg)
}
pub fn trash_comment() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("comments" / String / String)
.and(warp::delete())
.and_then(handlers::trash_comment)
}
pub fn update_reply_msg() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("reply_message")
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::update_reply_msg)
}
pub fn add_reply() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("replies")
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::add_reply)
}
pub fn trash_reply() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("replies" / String )
.and(warp::delete())
.and_then(handlers::trash_reply)
}
pub fn get_static_file() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("static" / String)
.and(warp::get())
.and_then(handlers::get_static_file)
}
pub fn get_image() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("images" / String)
.and(warp::get())
.and_then(handlers::get_image)
}
pub fn get_icon() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("images" / String / String)
.and(warp::get())
.and_then(handlers::get_image_type)
}
pub fn upvote() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("upvotes")
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::upvote)
}
pub fn downvote() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
warp::path!("downvotes")
.and(warp::post())
.and(warp::body::form())
.and_then(handlers::downvote)
}