Book Image

Building RESTful Web services with Go

By : Naren Yellavula
Book Image

Building RESTful Web services with Go

By: Naren Yellavula

Overview of this book

REST is an architectural style that tackles the challenges of building scalable web services and in today's connected world, APIs have taken a central role on the web. APIs provide the fabric through which systems interact, and REST has become synonymous with APIs. The depth, breadth, and ease of use of Go, makes it a breeze for developers to work with it to build robust Web APIs. This book takes you through the design of RESTful web services and leverages a framework like Gin to implement these services. The book starts with a brief introduction to REST API development and how it transformed the modern web. You will learn how to handle routing and authentication of web services along with working with middleware for internal service. The book explains how to use Go frameworks to build RESTful web services and work with MongoDB to create REST API. You will learn how to integrate Postgres SQL and JSON with a Go web service and build a client library in Go for consuming REST API. You will learn how to scale APIs using the microservice architecture and deploy the REST APIs using Nginx as a proxy server. Finally you will learn how to metricize a REST API using an API Gateway. By the end of the book you will be proficient in building RESTful APIs in Go.
Table of Contents (20 chapters)
Title Page
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Chapter 4. Simplifying RESTful Services with Popular Go Frameworks

In this chapter, we are going to cover topics related to using a framework for simplifying building REST services. First, we will take a quick look at go-restful, a REST API creation framework, and then move on to a framework called Gin. We will try to build a Metro Rail API in this chapter. The frameworks we are about to discuss are fully-fledged web frameworks which can also be used to create REST APIs in a short time. We will talk a lot about resources and REST verbs in this chapter. We will try to integrate a small database called Sqlite3 with our API. Finally, we will inspect Revel.go and see how to prototype our REST API with it.

Overall, the topics we will cover in this chapter are as follows:

  • How to use SQLite3 in Go
  • Creating a REST API with the go-restful package
  • Introducing the Gin framework for creating a REST API
  • Introducing Revel.go for creating a REST API
  • Basics for building CRUD operations