actix / actix/actix-web

Extract path arguments in middleware before processing the request

Offen
#2,096 6 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
A-router
Vorherrschende Sprache
Rust
Sterne
24.8k
Forks
1.9k
Ø Merge
23 Std. 10 Min.
Gemergte PRs (30 T.)
26

Beschreibung

As per https://github.com/actix/actix-web/issues/1784#issue-739668855, the path arguments in middleware are not accessible until after the request is processed.

## Expected Behavior
`actix_web::web::Path::::from_request(request, payload)` in a service call returns path argument(s) at any point in the service call.

## Current Behavior
Output of request.match_info(), request.match_pattern() and actix_web::web::Path::::from_request(request, payload) from inside the service call: "wrong number of parameters: 0 expected 1".

## Steps to Reproduce (for bugs)

1. Implement a middleware service, with the Path extractor
2. Call the middleware on a route which takes a path argument

## Context
I am trying to implement guards on the URL path to ensure that users can only access what they are allowed to access. Only being able to access the patch arguments after the request means that it is not possible to use this method for endpoints that update information

## Your Environment

Rust Version: 1.50.0
Actix Web Version: 3.3.2

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.