更新时间:2021-07-02 20:14:35
封面
版权信息
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Getting Started with REST API Development
Types of web services
REST API
Characteristics of REST services
REST verbs and status codes
GET
POST PUT and PATCH
DELETE and OPTIONS
Cross-Origin Resource Sharing (CORS)
Types of status codes
2xx family (successful)
3xx family (redirection)
4xx family (client error)
5xx family (server error)
Rise of REST API with Single Page Applications
Old and new ways of data flow in SPA
Why Go for REST API development?
Setting up the project and running the development server
Demystifying GOPATH
Building our first service – finding the Roman numeral
Breaking down the code
Live reloading the application with supervisord and Gulp
Monitoring your Go web server with supervisord
Installing supervisord
Using Gulp for creating auto code compiling and server reloading
Understanding the gulpfile
Summary
Handling Routing for Our REST Services
Getting the code
Understanding Go's net/http package
Running the code
ServeMux a basic router in Go
Adding multiple handlers using ServeMux
Introducing httprouter a lightweight HTTP router
Installation
Program explanation
Building the simple static file server in minutes
Introducing Gorilla Mux a powerful HTTP router
Fundamentals of Gorilla Mux
Reverse mapping URL
Custom paths
Path Prefix
Strict Slash
Encoded paths
Query-based matching
Host-based matching
SQL injections in URLs and ways to avoid them
Creating a basic API layout for URL shortening services
Working with Middleware and RPC
What is middleware?
Creating a basic middleware
Multiple middleware and chaining
Painless middleware chaining with Alice
Using Gorilla's Handlers middleware for Logging
What is RPC?
Creating an RPC server
Creating an RPC client
JSON RPC using Gorilla RPC
Simplifying RESTful Services with Popular Go Frameworks
go-restful a framework for REST API creation
CRUD operations and SQLite3 basics
Building a Metro Rail API with go-restful
Design specification
Creating database models
Building RESTful APIs with the Gin framework
Building a RESTful API with Revel.go
Working with MongoDB and Go to Create REST APIs
Introduction to MongoDB
Installing MongoDB and using the shell
Working with the Mongo shell