Giter Club home page Giter Club logo

Comments (8)

chrislearn avatar chrislearn commented on August 31, 2024

I don't quite understand the feature you said, can you give example actix code about it?

from salvo.

Murtuzakabul avatar Murtuzakabul commented on August 31, 2024

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.

chrislearn avatar chrislearn commented on August 31, 2024

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.

Murtuzakabul avatar Murtuzakabul commented on August 31, 2024

Seems like the correct solution.

from salvo.

sysmat avatar sysmat commented on August 31, 2024
  • 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.

sysmat avatar sysmat commented on August 31, 2024

is it possible to have routes guard/grant by roles some thing like https://crates.io/crates/actix-web-grants

from salvo.

chrislearn avatar chrislearn commented on August 31, 2024

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.

DDtKey avatar DDtKey commented on August 31, 2024

For anyone interested: https://github.com/DDtKey/protect-endpoints now supports salvo 🎉

from salvo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.