Files
fn-serverless/examples/blog/routes/post_read.go
2017-04-19 09:49:12 -06:00

27 lines
400 B
Go

package route
import (
"os"
"github.com/kumokit/functions/examples/blog/database"
)
func HandlePostRead(db *database.Database, auth map[string]interface{}) {
id := os.Getenv("PARAM_ID")
if id == "" {
SendError("Missing post ID")
return
}
post, err := db.GetPost(id)
if err != nil {
SendError("Couldn't retrieve that post")
return
}
SendResponse(Response{
"post": post,
})
}