Comparison

mod_http_muc_log/mod_http_muc_log.lua @ 1576:91b91052e0e8

mod_http_muc_log: Send a HTML mime type with responses
author Kim Alvefur <zash@zash.se>
date Thu, 20 Nov 2014 19:50:43 +0100
parent 1575:464ed6bc5a73
child 1577:0a6974f2cb55
comparison
equal deleted inserted replaced
1575:464ed6bc5a73 1576:91b91052e0e8
235 next_day = datetime.parse(next_day .. "T23:59:59Z") + 1; 235 next_day = datetime.parse(next_day .. "T23:59:59Z") + 1;
236 break; 236 break;
237 end 237 end
238 until not next_day; 238 until not next_day;
239 239
240 response.headers.content_type = "text/html";
240 return dates_template{ 241 return dates_template{
241 host = module.host; 242 host = module.host;
242 canonical = module:http_url() .. "/" .. path; 243 canonical = module:http_url() .. "/" .. path;
243 room = room; 244 room = room;
244 lines = table.concat(dates); 245 lines = table.concat(dates);
307 prev_when = datetime.date(when); 308 prev_when = datetime.date(when);
308 module:log("debug", "Previous message: %s", datetime.datetime(when)); 309 module:log("debug", "Previous message: %s", datetime.datetime(when));
309 break; 310 break;
310 end 311 end
311 312
313 response.headers.content_type = "text/html";
312 return page_template{ 314 return page_template{
313 canonical = module:http_url() .. "/" .. path; 315 canonical = module:http_url() .. "/" .. path;
314 host = module.host; 316 host = module.host;
315 room = room; 317 room = room;
316 date = date; 318 date = date;
329 name = room:get_name(); 331 name = room:get_name();
330 description = room:get_description(); 332 description = room:get_description();
331 }, i + 1; 333 }, i + 1;
332 end 334 end
333 end 335 end
336
337 event.response.headers.content_type = "text/html";
334 return room_list_template { 338 return room_list_template {
335 host = module.host; 339 host = module.host;
336 canonical = module:http_url() .. "/"; 340 canonical = module:http_url() .. "/";
337 rooms = table.concat(room_list); 341 rooms = table.concat(room_list);
338 }; 342 };
353 module:log("debug", "Client cache hit"); 357 module:log("debug", "Client cache hit");
354 return 304; 358 return 304;
355 end 359 end
356 module:log("debug", "Server cache hit"); 360 module:log("debug", "Server cache hit");
357 response.headers.etag = etag; 361 response.headers.etag = etag;
362 response.headers.content_type = "text/html";
358 return cached[1]; 363 return cached[1];
359 end 364 end
360 365
361 local start = gettime(); 366 local start = gettime();
362 local render = f(event, path); 367 local render = f(event, path);
367 cached = { render, etag = etag, date = datetime.date() }; 372 cached = { render, etag = etag, date = datetime.date() };
368 response.headers.etag = etag; 373 response.headers.etag = etag;
369 cache[ckey] = cached; 374 cache[ckey] = cached;
370 end 375 end
371 376
377 response.headers.content_type = "text/html";
372 return render; 378 return render;
373 end 379 end
374 end 380 end
375 381
376 -- How is cache invalidation a hard problem? ;) 382 -- How is cache invalidation a hard problem? ;)