remove expressjs from skins

This commit is contained in:
jomo 2015-01-02 22:58:38 +01:00
parent 0009535fc0
commit 2f4951311d

View File

@ -2,19 +2,22 @@ var networking = require("../modules/networking");
var logging = require("../modules/logging"); var logging = require("../modules/logging");
var helpers = require("../modules/helpers"); var helpers = require("../modules/helpers");
var config = require("../modules/config"); var config = require("../modules/config");
var router = require("express").Router();
var skins = require("../modules/skins"); var skins = require("../modules/skins");
var lwip = require("lwip"); var lwip = require("lwip");
/* GET skin request. */ // GET skin request
router.get("/:uuid.:ext?", function(req, res) { module.exports = function(req, res) {
var uuid = (req.params.uuid || "");
var def = req.query.default;
var start = new Date(); var start = new Date();
var uuid = (req.url.pathname.split("/")[2] || "").split(".")[0];
var def = req.url.query.default;
var etag = null; var etag = null;
if (!helpers.uuid_valid(uuid)) { if (!helpers.uuid_valid(uuid)) {
res.status(422).send("422 Invalid UUID"); res.writeHead(422, {
"Content-Type": "text/plain",
"Response-Time": new Date() - start
});
res.end("Invalid UUID");
return; return;
} }
@ -28,7 +31,7 @@ router.get("/:uuid.:ext?", function(req, res) {
logging.error(uuid + " " + err); logging.error(uuid + " " + err);
} }
etag = hash && hash.substr(0, 32) || "none"; etag = hash && hash.substr(0, 32) || "none";
var matches = req.get("If-None-Match") == '"' + etag + '"'; var matches = req.headers["if-none-match"] == '"' + etag + '"';
if (image) { if (image) {
var http_status = 200; var http_status = 200;
if (matches) { if (matches) {
@ -36,7 +39,7 @@ router.get("/:uuid.:ext?", function(req, res) {
} else if (err) { } else if (err) {
http_status = 503; http_status = 503;
} }
logging.debug("Etag: " + req.get("If-None-Match")); logging.debug("Etag: " + req.headers["if-none-match"]);
logging.debug("matches: " + matches); logging.debug("matches: " + matches);
logging.log("status: " + http_status); logging.log("status: " + http_status);
sendimage(http_status, image); sendimage(http_status, image);
@ -81,7 +84,4 @@ router.get("/:uuid.:ext?", function(req, res) {
}); });
res.end(http_status == 304 ? null : image); res.end(http_status == 304 ? null : image);
} }
}); };
module.exports = router;