annotate examples/blog/src/delete.luan @ 1437:3e185b27f982

Http.request.body
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 07 Jan 2020 21:03:57 -0700
parents bc40bc9aab3a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1387
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local String = require "luan:String.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local to_number = String.to_number or error()
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Http = require "luan:http/Http.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Post = require "site:/lib/Post.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 return function()
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local post_id = to_number(Http.request.parameters.post) or error()
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 Post.delete_by_id(post_id)
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 Http.response.send_redirect("/")
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 end