Gin: A Website Application Framework for Go

This course will introduce you to Gin and show you how to get started with it to build your own web applications.
Course info
Rating
(20)
Level
Intermediate
Updated
Feb 26, 2016
Duration
2h 35m
Table of contents
Description
Course info
Rating
(20)
Level
Intermediate
Updated
Feb 26, 2016
Duration
2h 35m
Description

Gin is one of the most popular web application frameworks available for Go. It comes with a wide variety of options to customize the way that requests are handled and responses are generated. This course will introduce you to Gin and show you how to get started with it to build your own web applications.

About the author
About the author

Michael Van Sickle is an application architect in Akron, Ohio. He is a mechanical engineer by training and a software engineer by choice. He is passionate about learning new programming languages and user experience design.

More from the author
The Go CLI Playbook
Intermediate
2h 8m
28 Feb 2018
Intern 4: Getting Started
Beginner
2h 41m
9 Jan 2018
Object-oriented Programming with Go
Intermediate
1h 42m
11 Aug 2017
More courses by Mike Van Sickle
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Michael Van Sickle and welcome to my course, Gin: A Web Application Framework for Go. I'm a software engineer at SitePen. There are many web frameworks springing up in the Go community, and it can be hard to decide which one to choose. In this course we'll go over the major features of Gin, so that you can decide if it's the right choice for your team. Some of the major topics that we'll cover include, how to configure routing, how to work with requests, including how to validate incoming data, how to formulate responses to requests, and how to work with middleware. By the end of this course you'll know how to get started with Gin. Before beginning the course you should be familiar with both the Go language, as well as how web applications work. I hope you'll join me on this journey to learn Gin with this course at Pluralsight.

Routing
Hello. My name is Michael Van Sickle, and welcome back to this discussion about Gin: A Web Framework for Go. In the last module I focused on an overview that's really intended to give you the high points, but didn't really give you a lot of detail about what Gin was and how it worked. Well now I'm going to start to turn that discussion around and get into some meat as we dig in to routing and how that works with Gin. I want to start our discussion now by talking about basic URL routing. This is just the very, very simple take a URL path, and map that over to a handler in our application. After that we're logically going to flow into how to load static resources, that is your Javascript, CSS, image files, and get those into your web application. After that we're going to move on to parameterized routes, and learn how to encode information into the URLs themselves, and retrieve that information for use by our handlers. Then we'll wrap up our discussion with a brief survey of the security mechanisms that are built-in to Gin. Okay, so let's start out by talking about how we're going to inject basic routing into our application.

Working with Requests
Hello, and welcome back to this journey through the Gin web application framework. In the last module we talked about how to setup a routing scheme, and setup handlers to work with requests from clients. Now we're going to dig in to the request processing itself, and see what features Gin has to offer for us. We'll start out simply by learning how to work with single values. Those values can come into our application in basically three different forms. First, we'll see route parameters again, and review how to pull information from the URL itself into our handler. Then we'll move onto query parameters, and learn how to process them, and pull data out of them, and finally, we'll work with HTML form data that's coming into our application, and learn how to pull data from those forms one field at a time. Of course, working with a single field at a time isn't the most efficient way to work with many applications data, and so we'll move on to learning how to retrieve entire objects at one time, and finally, we'll talk about Gin's data validation framework, and we'll see how, despite what the documentation may imply, there's a very, very rich ecosystem here due to another library that Gin leverages. Okay, let's start talking about how to pull single values into our application.

Middleware
Welcome back to this final module where we're talking about Gin, a web framework for Go. In the last few modules we've covered the primary path that HTTP requests are going to take through your application. We started by learning how to register our handlers, then we moved on to request processing, and in the last module we talked about the many options that Gin offers us for formulating responses, and sending those back to the requester. Now it's time to talk about middleware, and how that can be used to augment our application and improve its functionality. We're going to start our discussion with an introduction to what exactly middleware is. Now middleware goes by several different names, but that's the name that seems to be hanging around in the Gin community, so that's the name we're going to go with. We'll then learn how we can have one piece of middleware communicate with other pieces of middleware or the main handlers that are setup to handle each individual request. Next, we'll talk about the many pre-packaged options that Gin contains, and get an overview of what those middlewares do, and how you can use those to enhance your application. Finally, we'll talk about custom middleware. While there are many pre-packaged options available in Gin there's almost always going to be some case where you need to have your own piece of middleware to solve a unique problem. We'll talk about that as a wrap-up to this module. Okay, so let's dive in and learn exactly what middleware is anyway.