annotate examples/blog/src/delete.luan @ 1502:8a7b6b32c691

minor threads
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 10 May 2020 22:48:15 -0600
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