actix / actix/actix-web

Extract path arguments in middleware before processing the request

Aperta
#2,096 6 commenti 1 reazione 0 assegnatari Vedi su GitHub
A-router
Lingua principale
Rust
Stelle
24.8k
Fork
1.9k
Merge medio
23h 10m
PR unite (30g)
26

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.