-
Notifications
You must be signed in to change notification settings - Fork 0
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 #123 from sima-land/38-refactor-for-redirects
Шаг 76 #38 Рефакторинг для редиректов
- Loading branch information
Showing
21 changed files
with
253 additions
and
191 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
import type { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
import accepts from 'accepts'; | ||
|
||
/** | ||
* Провайдер функции, которая определяет возможные типы ответа и их приоритет. | ||
* @param resolve Resolve. | ||
* @return Функция. | ||
*/ | ||
export function provideAcceptType(resolve: Resolve) { | ||
const context = resolve(KnownToken.Http.Handler.context); | ||
|
||
// @todo опасное место, будем решать как исправлять по итогам https://github.com/jshttp/accepts/issues/30 | ||
const accept = accepts({ | ||
headers: Object.fromEntries(context.request.headers.entries()), | ||
} as any); | ||
|
||
return accept.type.bind(accept); | ||
} |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,13 @@ | ||
import type { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
|
||
/** | ||
* Провайдер функции, которая определяет возможные типы ответа и их приоритет. | ||
* @param resolve Resolve. | ||
* @return Функция. | ||
*/ | ||
export function provideAcceptType(resolve: Resolve) { | ||
const context = resolve(KnownToken.ExpressHandler.context); | ||
|
||
return context.req.accepts.bind(context.req); | ||
} |
Oops, something went wrong.