mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
27 lines
400 B
Go
27 lines
400 B
Go
package route
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/iron-io/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,
|
|
})
|
|
}
|