diff --git a/controllers/pastes.js b/controllers/pastes.js index 3c21fd7..9290929 100644 --- a/controllers/pastes.js +++ b/controllers/pastes.js @@ -4,6 +4,16 @@ const isBinaryFile = require('isbinaryfile').isBinaryFile; const Paste = require('../models/paste'); module.exports = { + async index(ctx) { + await ctx.render('index', { + pretty: config.prettyHtml, + title: config.name, + url: ctx.request.origin, + expires: config.expires, + highlights: config.highlights + }); + }, + async view(ctx) { try { const paste = await Paste.findById(ctx.params.id).exec(); diff --git a/router.js b/router.js index 696024e..0a09685 100644 --- a/router.js +++ b/router.js @@ -22,18 +22,7 @@ const body = require('koa-body')({ const pastes = require('./controllers/pastes'); router - .get('/', conditional, etag, async (ctx) => { - ctx.set('Cache-Control', 'public'); - - await ctx.render('index', { - pretty: config.prettyHtml, - title: config.name, - url: ctx.request.origin, - expires: config.expires, - expiresDefault: config.expiresDefault, - highlights: config.highlights - }); - }) + .get('/', conditional, etag, pastes.index) .post('/', body, pastes.create) .get('/:id', conditional, etag, pastes.view);