Created
February 2, 2014 16:02
-
-
Save techslides/8770473 to your computer and use it in GitHub Desktop.
Martini Quick Error Check and Rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learn more about this code here: http://techslides.com/simple-app-with-go-martini-gorp-and-mysql/