mirror of
https://github.com/cupcakearmy/koa-cookie.git
synced 2024-12-22 16:16:29 +00:00
Changed to cca-koa-router
This commit is contained in:
parent
e14e97a4e9
commit
957c20e89a
11
README.md
11
README.md
@ -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: '/',
|
||||||
|
@ -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": {
|
||||||
|
Loading…
Reference in New Issue
Block a user