Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: middlewares wont work with dynamic routes #136

Closed
renancaraujo opened this issue Jul 4, 2022 · 2 comments · Fixed by #350
Closed

fix: middlewares wont work with dynamic routes #136

renancaraujo opened this issue Jul 4, 2022 · 2 comments · Fixed by #350
Assignees
Labels
bug Something isn't working as expected
Milestone

Comments

@renancaraujo
Copy link
Contributor

Description

Middlewares inside dynamic routes are not recognized.

Steps To Reproduce

  1. Create a frog server with the following route structure
routes/
  - _middleware.dart
  - [id]/
    - index.dart
    - _middleware.dart
  1. On the root middleware, put the following content:
import 'package:dart_frog/dart_frog.dart';

Handler middleware(Handler handler) {
  return handler
      .use(provider<String>((context) {
    return 'root middleware haha';
  }));
}
  1. On the middleware under /[id], put the following content:
import 'package:dart_frog/dart_frog.dart';

Handler middleware(Handler handler) {
  return handler
      .use(provider<String>((context) {
    return 'id middleware hihi';
  }));
}
  1. On /[id]/index.dart put the following content:
import 'package:dart_frog/dart_frog.dart';

Response onRequest(RequestContext context) {
  final thingy = context.read<String>();
  return Response(body: 'result: $thingy');
}
  1. Start the server and go to http://localhost:8080/someid
  2. See the result: result: root middleware haha

Expected Behavior

The handler at /[id]/index.dart should; receive a context with information for the closest middleware, not the root one.

Additional Context

Reproducible with the CLI version 0.0.2-dev.7

@renancaraujo renancaraujo added the bug Something isn't working as expected label Jul 4, 2022
@felangel felangel self-assigned this Jul 4, 2022
@felangel felangel moved this to In Progress in VGV Open Source 🦄 🧙🌟 Jul 4, 2022
@felangel
Copy link
Contributor

felangel commented Jul 4, 2022

related to dart-lang/shelf#250 and google/dart-neats#40

@felangel felangel moved this from In Progress to Blocked in VGV Open Source 🦄 🧙🌟 Jul 5, 2022
@felangel felangel added this to the 0.1.0 milestone Jul 11, 2022
@felangel felangel modified the milestones: 0.1.0, 1.0.0 Jul 22, 2022
@BeatriceMitchell
Copy link

BeatriceMitchell commented Jul 28, 2022

Descoping from 0.1, moving to 1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants