UNPKG

node-web-mvc

Version:
61 lines (60 loc) 1.46 kB
/** * @module ResponseEntity */ import CacheControl from '../http/CacheControl'; import MediaType from '../http/MediaType'; import { RequestHeaders } from '../../interface/declare'; export default class HttpEntity<T = any, H = RequestHeaders> { headers: H; body: T; constructor(data: T, headers: H); /** * 设置返回内容 * @param data */ setBody(data: T): this; /** * 这是头部信息对象 * @param headers */ setHeaders(headers: any): this; /** * 设置单个头部信息 * @param key * @param values */ setHeader(key: string, ...values: Array<string>): this; /** * 设置头部信息 allows * @param HttpMethod * @param allowedMethods */ setAllow(allowedMethods: Array<string>): this; /** * 设置返回etag */ setETag(etag: string): this; /** * 设置Last-Modified头部信息 */ setLastModified(lastModified: Date): this; /** * 设置Location头部信息 */ setLocation(location: string): this; /** * 配置缓存控制 */ setCacheControl(cacheControl: CacheControl): this; /** * 配置 Vary头部信息 * ```js * .varBy('UserAgent','Cookie') * * ``` */ setVaryBy(requestHeaders: Array<string>): this; setContentLength(contentLength: number): this; setContentType(contentType: MediaType): this; build(): void; }