cdn_cache.js 916 Bytes
/**
 *
 * @author: chenfeng<feng.chen@yoho.cn>
 * @date: 16/10/19
 */

'use strict';

import Router from 'koa-router';
import {
    CdnCache
} from '../../models'

const r = new Router();

const cdnCache = {
    async query(ctx) {
        let date = {
            typeList: [{
                name: '文件',
                typeName: 'File',
            }, {
                name: '目录',
                typeName: 'Directory',
            }]
        }
        await ctx.render('action/cdn_cache', date);
    },
    async clear(ctx) {
        let queryUris = ctx.request.body.query_uri;
        let objectType = ctx.request.body.object_type;
        if (queryUris.trim() && objectType) {
            CdnCache.removeCache(queryUris, objectType);    
        }
        return ctx.body = {
            code: 200
        };
    }
}
r.get('/query', cdnCache.query);
r.post('/clear', cdnCache.clear);

export default r;