- Building RESTful Web services with Go
- Naren Yellavula
- 225字
- 2021-07-02 20:14:06
Handling Routing for Our REST Services
In this chapter, we will discuss routing of the application. For creating an API, the first step is to define routes. So, to define routes, we need to figure out available constructs in Go. We begin with the basic internal routing mechanism in Go. Then, we see how to create a custom Multiplexer. Since ServeMux's capabilities are very limited, we will explore a few other frameworks built to serve this purpose. This chapter also includes creating routes using third-party libraries such as httprouter and Gorilla Mux. We are going to build a URL-shortening API throughout this book. In this chapter, we define routes for the API. Then, we discuss topics like SQL injection of an URL. A web framework allows the developer to create a route as the first step and then attach handlers to it. Those handlers hold the business logic of the application. The crux of this chapter is teaching you how to create HTTP routers in Go using Gorilla Mux. We also discuss how URL-shortening service functions and try to design a logical implementation.
We will cover the following topics:
- Building a basic web server in Go
- Understanding the net/http package
- ServeMux, a basic router in Go
- Understanding httprouter, a router package
- Introducing Gorilla Mux, a powerful HTTP router
- Introducing URL shortening service design
- 廣電5G從入門到精通
- RCNP實驗指南:構建高級的路由互聯網絡(BARI)
- 物聯網安全(原書第2版)
- 從區塊鏈到Web3:構建未來互聯網生態
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- 信息通信網絡建設安全管理概要2
- 網絡安全技術與解決方案(修訂版)
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- 雷達饋線技術
- 城域網與廣域網(第2版)
- Unity Artificial Intelligence Programming
- 光纖通信系統與網絡(修訂版)
- 互聯網安全的40個智慧洞見(2016)
- Selenium WebDriver 3 Practical Guide
- 商業的本質和互聯網