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

OAuth 2 architecture and basics


OAuth 2 is an authentication framework that is used to create authentication pattern between different systems. In this, the client, instead of making a request to the resource server, makes an initial request for some entity called resource owner. This resource owner gives back the authentication grant for the client (if credentials are successful). The client now sends this authentication grant to another entity called an authentication server. This authentication server takes the grant and returns an access token. This token is the key thing for a client to access API resources. It needs to make an API request to the resource server with this access token and the response is served. In this entire flow, the second part can be done using JWT. Before that, let us learn the difference between authentication and authorization.

Authentication versus authorization

Authentication is the process of identifying whether a client is genuine or not. When a server authenticates...