Changed to cca-koa-router

This commit is contained in:
nicco 2017-08-21 00:23:50 +02:00
parent e14e97a4e9
commit 957c20e89a
2 changed files with 7 additions and 8 deletions

View File

@ -5,14 +5,13 @@ Lightweight Koa-Middleware for Cookies
```javascript ```javascript
const const
Koa = require('koa'), Koa = require('koa'),
router = require('koa-simple-router'), cookie = require('cca-koa-cookie'),
cookie = require('cca-koa-cookie') router = require('cca-koa-router')
const const
app = new Koa(), app = new Koa(),
port = 3000 port = 3000
// Parse Parameters
app.use(cookie) app.use(cookie)
app.use(router({}, _ => { app.use(router({}, _ => {
@ -28,11 +27,11 @@ app.use(router({}, _ => {
secure: false secure: false
}) })
c.body = [200, 'Cookie Set'] c.body = 'Cookie Set'
}) })
_.get('/get', (c, n) => { _.get('/get', (c, n) => {
c.body = [200, c.request.cookies] c.body = c.request.cookies
}) })
})) }))
@ -52,7 +51,7 @@ The Parser also defines a getter and setter for cookies
###### Example ###### Example
```javascript ```javascript
// Set a cookie // Set a cookie
c.request.cookie.set({ ctx.request.cookie.set({
key: 'my_id', key: 'my_id',
value: '12345678', value: '12345678',
path: '/', path: '/',

View File

@ -1,6 +1,6 @@
{ {
"name": "cca-koa-cookie", "name": "cca-koa-cookie",
"version": "0.1.2", "version": "0.1.3",
"description": "Cookie Parser and Setter for Koa", "description": "Cookie Parser and Setter for Koa",
"main": "Cookie.js", "main": "Cookie.js",
"repository": { "repository": {
@ -20,4 +20,4 @@
"url": "https://github.com/CupCakeArmy/koa-cookie/issues" "url": "https://github.com/CupCakeArmy/koa-cookie/issues"
}, },
"homepage": "https://github.com/CupCakeArmy/koa-cookie#readme" "homepage": "https://github.com/CupCakeArmy/koa-cookie#readme"
} }