-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dandi/mvc-view): support content-negotiated views
- use multiple `@View` decorators to configure multiple view options differentiated by MIME type or other request header closes #66
- Loading branch information
1 parent
2bc56ac
commit 5f9a676
Showing
11 changed files
with
472 additions
and
136 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 |
---|---|---|
@@ -1,14 +1,32 @@ | ||
import { HttpRequestHeaders, MimeType } from '@dandi/http' | ||
import { ControllerMethodMetadata } from '@dandi/mvc' | ||
|
||
import { RenderOptions } from './render-options' | ||
|
||
export type HttpRequestHeaderFunctionComparer<THeaderName extends keyof HttpRequestHeaders> = | ||
(value: HttpRequestHeaders[THeaderName]) => boolean | ||
|
||
export type HttpRequestHeaderComparer<THeaderName extends keyof HttpRequestHeaders> = | ||
HttpRequestHeaderFunctionComparer<THeaderName> | HttpRequestHeaders[THeaderName] | ||
|
||
export type HttpRequestHeaderComparers = { | ||
[THeaderName in keyof HttpRequestHeaders]?: | ||
HttpRequestHeaders[THeaderName] extends string ? | ||
// allow regexps for headers with plain string values | ||
RegExp | HttpRequestHeaderComparer<THeaderName> : | ||
HttpRequestHeaderComparer<THeaderName> | ||
} | ||
|
||
export type ViewFilter = MimeType | HttpRequestHeaderComparers | ||
|
||
export interface ViewMetadata { | ||
name: string | ||
path?: string | ||
context: string | ||
options?: RenderOptions | ||
filter?: ViewFilter[] | ||
} | ||
|
||
export interface ControllerViewMethodMetadata extends ControllerMethodMetadata { | ||
view?: ViewMetadata | ||
views?: ViewMetadata[] | ||
} |
Oops, something went wrong.