Skip to content

Instantly share code, notes, and snippets.

@techslides
Created February 2, 2014 16:02
Show Gist options
  • Save techslides/8770473 to your computer and use it in GitHub Desktop.
Save techslides/8770473 to your computer and use it in GitHub Desktop.
Martini Quick Error Check and Rendering
m.Get("/:id", func(args martini.Params, r render.Render) {
var post Post
err = dbmap.SelectOne(&post, "select * from posts where post_id=?", args["id"])
//simple error check
if err != nil {
r.HTML(404, "error", "This post is not found.")
} else {
r.HTML(200, "post", post)
}
})
@techslides
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment