make post and put work the same way
This commit is contained in:
parent
1c36339db7
commit
2226dabf54
|
@ -23,10 +23,13 @@ const App = (counter) => {
|
|||
ctx.body = await counter.metrics()
|
||||
})
|
||||
|
||||
router.put('/clicks/:id', async ctx => {
|
||||
const clickIncrement = async ctx => {
|
||||
ctx.body = { [ctx.params.id]: await counter.incr(ctx.params.id) }
|
||||
ctx.status = 201
|
||||
})
|
||||
}
|
||||
|
||||
router.put('/clicks/:id', clickIncrement)
|
||||
router.post('/clicks/:id', clickIncrement)
|
||||
|
||||
router.get('/clicks', async ctx => {
|
||||
ctx.body = await counter.list()
|
||||
|
|
Loading…
Reference in New Issue