Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11785 from nestjs/fix/middleware-for-versioned-ctrls
fix(core): apply middleware to versioned controllers (ctrl-level)
- Loading branch information
Showing
9 changed files
with
251 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Controller, Get, Version } from '@nestjs/common'; | ||
|
||
@Controller({ | ||
path: 'middleware', | ||
version: '1', | ||
}) | ||
export class MiddlewareController { | ||
@Get('/') | ||
hello() { | ||
return 'Hello from "MiddlewareController"!'; | ||
} | ||
|
||
@Version('2') | ||
@Get('/override') | ||
hellov2() { | ||
return 'Hello from "MiddlewareController"!'; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
integration/versioning/src/multiple-middleware.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
@Controller({ | ||
version: ['1', '2'], | ||
path: 'middleware', | ||
}) | ||
export class MultipleMiddlewareVersionController { | ||
@Get('/multiple') | ||
multiple() { | ||
return 'Multiple Versions 1 or 2'; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
integration/versioning/src/neutral-middleware.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Get, VERSION_NEUTRAL } from '@nestjs/common'; | ||
|
||
@Controller({ | ||
path: 'middleware', | ||
version: VERSION_NEUTRAL, | ||
}) | ||
export class VersionNeutralMiddlewareController { | ||
@Get('/neutral') | ||
neutral() { | ||
return 'Neutral'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.