Comments (8)
I don't quite understand the feature you said, can you give example actix code about it?
from salvo.
https://docs.rs/actix-web/3.3.3/actix_web/guard/index.html
A guard is simply a function which returns a boolean which determines if the route could be navigated to or not. This function gets invoked before the route gets executed and if the function returns false, the route does not get executed and may return 404 or 401 as configured.
from salvo.
It looks like Router's filter. In salvo, Router::get, Router::post... are just filter.
https://docs.rs/salvo_core/latest/salvo_core/routing/struct.Router.html#method.filter_fn
from salvo.
Seems like the correct solution.
from salvo.
filter_fn
can't be async is there any other way to , let say in filter_fn must do some async validation operation- should in async scenario to be hoop with async_trait
from salvo.
is it possible to have routes guard/grant by roles some thing like https://crates.io/crates/actix-web-grants
from salvo.
Filter is not supports async in current version.
If you want to protected your router, you can use middleware.
Router::with_path("aaa").push(Router::with_hoop(check).path("bb"))
from salvo.
For anyone interested: https://github.com/DDtKey/protect-endpoints now supports salvo
🎉
from salvo.
Related Issues (20)
- Get matched route information HOT 1
- Add IpAddr and u16 "constructor" to conn::TcpListener HOT 1
- Enhance Error Handling in Compression Middleware to Properly Propagate Error(StatusError) in ResBody HOT 1
- implement IP filtering at the TCP level. HOT 1
- OAPI : #[salvo(schema(name = XXX))] expects an identifier instead of a "string" literal HOT 7
- OAPI : Short FlexNamer doesn't respect schemas name HOT 3
- `oapi::ToParameters` trait requires `oapi::Extractible` trait, which is not necessary HOT 1
- Error display in `StatusError` implementation
- 使用PathParam时,路由通配符<**id>不生效 HOT 3
- Rename Affix HOT 6
- Server Logs Only Show HTTP/1.1 with `http2-cleartext` Feature in `salvo` Crate HOT 3
- Additionally, even when I disable the `http2` feature, the server still handles HTTP/2 requests. I don't think it should behave this way. HOT 10
- Sentry documentation
- OpenAPI page does not render
- Rename hoop HOT 5
- Add compression support to websockets HOT 2
- Derive `ToSchema` not work for unit enum variants
- 根据例子设置自定义页面404,发现res.status_code 一直是None HOT 1
- session 失效了
- 0.71.1: cannot call non-const fn `Identity::new` in constant functions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from salvo.