5htp-core 0.5.1-93 → 0.5.1-94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.5.1-
|
|
4
|
+
"version": "0.5.1-94",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -124,8 +124,6 @@ export default class ServerResponse<
|
|
|
124
124
|
|
|
125
125
|
// Run controller
|
|
126
126
|
const content = await this.route.controller( context );
|
|
127
|
-
|
|
128
|
-
// Handle content type
|
|
129
127
|
if (content === undefined)
|
|
130
128
|
return;
|
|
131
129
|
|
|
@@ -225,6 +223,11 @@ export default class ServerResponse<
|
|
|
225
223
|
- DATA RESPONSE
|
|
226
224
|
----------------------------------*/
|
|
227
225
|
|
|
226
|
+
public type( mimetype: string ) {
|
|
227
|
+
this.headers['Content-Type'] = mimetype;
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
|
|
228
231
|
public async render( page: Page, context: TRouterContext, additionnalData: {} ) {
|
|
229
232
|
|
|
230
233
|
// Set page in context for the client side
|
|
@@ -272,19 +275,17 @@ export default class ServerResponse<
|
|
|
272
275
|
this.headers['Content-Type'] = 'text/xml';
|
|
273
276
|
this.data = xml;
|
|
274
277
|
return this.end();
|
|
275
|
-
|
|
276
278
|
}
|
|
277
279
|
|
|
278
|
-
public text(text: string) {
|
|
280
|
+
public text(text: string, mimetype: string = 'text/plain') {
|
|
279
281
|
|
|
280
|
-
this.headers['Content-Type'] =
|
|
282
|
+
this.headers['Content-Type'] = mimetype;
|
|
281
283
|
this.data = text;
|
|
282
284
|
return this.end();
|
|
283
|
-
|
|
284
285
|
}
|
|
285
286
|
|
|
286
287
|
// TODO: https://github.com/adonisjs/http-server/blob/develop/src/Response/index.ts#L430
|
|
287
|
-
public async file( filename: string ) {
|
|
288
|
+
public async file( filename: string, mimetype?: string ) {
|
|
288
289
|
|
|
289
290
|
// Securité
|
|
290
291
|
if (filename.includes('..'))
|
|
@@ -317,7 +318,8 @@ export default class ServerResponse<
|
|
|
317
318
|
|
|
318
319
|
|
|
319
320
|
// Mimetype
|
|
320
|
-
|
|
321
|
+
if (mimetype !== undefined)
|
|
322
|
+
this.headers['Content-Type'] = mimetype;
|
|
321
323
|
|
|
322
324
|
return this.end();
|
|
323
325
|
}
|