UNPKG

2.93 kBTypeScriptView Raw
1/**
2 * @license
3 * MOST Web Framework 2.0 Codename Blueshift
4 * Copyright (c) 2017, THEMOST LP All rights reserved
5 *
6 * Use of this source code is governed by an BSD-3-Clause license that can be
7 * found in the LICENSE file at https://themost.io/license
8 */
9import {HttpContext} from "./context";
10import {HtmlWriter} from "@themost/common/html";
11import {HttpViewEngineConfiguration} from "./config";
12
13
14export declare class HttpResult {
15 /**
16 * @constructor
17 */
18 constructor();
19 contentType?: string;
20 contentEncoding?: string;
21
22 status(status?: number): HttpResult;
23
24 public execute(context: HttpContext, callback: (err?: Error) => void);
25}
26
27export declare class HttpContentResult extends HttpResult {
28
29 constructor(content: string|Buffer);
30
31 data: any;
32}
33
34export declare class HttpJsonResult extends HttpResult {
35
36 constructor(data: any);
37
38 data: any;
39}
40
41export declare class HttpXmlResult extends HttpResult {
42
43 constructor(data: any);
44
45 data: any;
46}
47
48export declare class HttpJavascriptResult extends HttpResult {
49
50 constructor(data: any);
51
52 data: any;
53}
54
55export declare class HttpViewResult extends HttpResult {
56 constructor(name?: string, data?: any);
57 setName(name: string): HttpViewResult;
58 static resolveViewPath(context: HttpContext, controller: string, view: string, engine: HttpViewEngineConfiguration, callback: (err?: Error, res?: string) => void);
59}
60
61
62export declare class HttpFileResult extends HttpResult {
63 constructor(physicalPath: string, fileName: string);
64 physicalPath: string;
65 fileName: string;
66
67}
68
69
70export declare class HttpRedirectResult extends HttpResult {
71 constructor(url: string);
72 url: string;
73
74}
75
76
77export declare class HttpEmptyResult extends HttpResult {
78 constructor();
79
80}
81
82
83export declare class HttpController {
84
85 context: HttpContext;
86 view(data?: any): HttpViewResult;
87 html(data?: any): HttpViewResult;
88 htm(data?: any): HttpViewResult;
89 js(script?: string): HttpJavascriptResult;
90 jsvar(name: string, obj: any): HttpJavascriptResult;
91 result(data?: any): HttpResult;
92 content(data?: any): HttpContentResult;
93 json(data?: any): HttpJsonResult;
94 xml(data?: any): HttpXmlResult;
95 file(physicalPath: string, fileName: string): HttpFileResult;
96 redirect(url: string): HttpRedirectResult;
97 empty(): HttpEmptyResult;
98 toPromise(resolver: (resolve: void, reject?: void) => Promise<any>): Promise<any>;
99 next(): HttpNextResult;
100
101}
102
103export declare class HttpViewContext {
104 constructor(context: HttpContext);
105 body?: string;
106 title?: string;
107 layout?: string;
108 data?: any;
109 context: HttpContext;
110 readonly writer: HtmlWriter;
111 readonly model: any;
112 init(): void;
113 render(url: string, callback: (err?: Error, res?: any) => void);
114 translate(key: string): string;
115}
116
117export declare class HttpNextResult extends HttpResult {
118 constructor();
119
120}
\No newline at end of file