Files
fn-serverless/examples/blog/routes/post_read.go
2017-05-29 17:10:47 -07:00

27 lines
407 B
Go

package route
import (
"os"
"gitlab-odx.oracle.com/odx/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,
})
}