Data, Maps, Usability, and Performance
Results for tag: martini
This is a continuation from the previous post on setting up Google App Engine with Go and Martini.
Last week, I showed how you can quickly create and launch a project with Google App Engine and Go. I integrated Martini on GAE and today, I will finish the tutorial by actually designing an API to properly respond to requests with JSON. I will also enable CORS and create some functions in GO that will shuffle an array of objects, split the array according to a user provided number, and reorder the array of objects for multiple keys. If we translate that to playing cards, the API will handle shuffling a deck, dealing out the cards to the amount of players provided, and ordering them by suit and numbers. Any remainder of cards based on provided players will go into the kitty. JSON is a popular content type so I will use that and follow the RESTful style of API design.
Google App Engine is a great platform for quickly developing and hosting web applications. There are alternatives but today we are going to dig into GAE and show how simple it is to get started. I have previously made a few posts on Go and Martini so today we are going to setup Martini on Google App Engine for the Go Language in order to launch an API in the cloud. Martini is a great framework for building a RESTful API and the workflow below will take you through all the steps, from downloading GoogleAppEngine to deploying our Martini API app:
Previously, I have created a really simple web app with Go Lang and Martini that communicated with MySQL to retrieve a list of posts, an individual post, and allowed creation of a post. Now, we are going to handle updates and deletion, transform responses to use JSON for client side Ajax requests, and implement the user relation: user login, logout, managing sessions and authentication, as well as, retrieving posts by user. Supporting PUT (update) and delete requests with Ajax and JSON was pretty trivial (thanks to Martini) but evolving the app to handle users properly with good validation was much more work then I originally expected. Still, Go does make the code easy to understand and Martini contributed utilities have been a great help. Lets start.
GoLang and Martini Web Application