[−][src]Function roa_router::allow
pub fn allow<E>(methods: impl AsRef<[Method]>, endpoint: E) -> Guard<E>
A function to construct guard by white list.
Only requests with http method in list can access this endpoint, otherwise will get a 405 METHOD NOT ALLOWED.
use roa_core::{App, Context, Result}; use roa_core::http::Method; use roa_router::allow; async fn foo(ctx: &mut Context<()>) -> Result { Ok(()) } let app = App::new(()).end(allow([Method::GET, Method::POST], foo));