mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Coding style tweaks
This commit is contained in:
parent
a986e4f7d6
commit
bab1bca485
@ -12,22 +12,21 @@ GET /
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var zlib = require('zlib');
|
var zlib = require("zlib");
|
||||||
|
|
||||||
exports.method = "GET";
|
exports.method = "GET";
|
||||||
|
|
||||||
exports.path = /^\/$/;
|
exports.path = /^\/$/;
|
||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var acceptEncoding = request.headers['accept-encoding'];
|
var acceptEncoding = request.headers["accept-encoding"];
|
||||||
if (!acceptEncoding) { acceptEncoding = ''; }
|
if(!acceptEncoding) {
|
||||||
|
acceptEncoding = "";
|
||||||
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler"));
|
}
|
||||||
|
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler")),
|
||||||
var responseHeaders = {
|
responseHeaders = {
|
||||||
"Content-Type": state.server.get("root-serve-type")
|
"Content-Type": state.server.get("root-serve-type")
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If the gzip=yes flag for `listen` is set, check if the user agent permits
|
If the gzip=yes flag for `listen` is set, check if the user agent permits
|
||||||
compression. If so, compress our response. Note that we use the synchronous
|
compression. If so, compress our response. Note that we use the synchronous
|
||||||
@ -36,14 +35,13 @@ exports.handler = function(request,response,state) {
|
|||||||
*/
|
*/
|
||||||
if(state.server.enableGzip) {
|
if(state.server.enableGzip) {
|
||||||
if (/\bdeflate\b/.test(acceptEncoding)) {
|
if (/\bdeflate\b/.test(acceptEncoding)) {
|
||||||
responseHeaders['Content-Encoding'] = 'deflate';
|
responseHeaders["Content-Encoding"] = "deflate";
|
||||||
text = zlib.deflateSync(text);
|
text = zlib.deflateSync(text);
|
||||||
} else if (/\bgzip\b/.test(acceptEncoding)) {
|
} else if (/\bgzip\b/.test(acceptEncoding)) {
|
||||||
responseHeaders['Content-Encoding'] = 'gzip';
|
responseHeaders["Content-Encoding"] = "gzip";
|
||||||
text = zlib.gzipSync(text);
|
text = zlib.gzipSync(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response.writeHead(200,responseHeaders);
|
response.writeHead(200,responseHeaders);
|
||||||
response.end(text);
|
response.end(text);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user