- 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
- Mastering Node.js(Second Edition)
- EDA技術(shù)與VHDL編程
- Building Django 2.0 Web Applications
- 新一代物聯(lián)網(wǎng)架構(gòu)技術(shù):分層算力網(wǎng)絡(luò)
- Spring Cloud微服務(wù)架構(gòu)進(jìn)階
- 面向物聯(lián)網(wǎng)的嵌入式系統(tǒng)開發(fā):基于CC2530和STM32微處理器
- 中國互聯(lián)網(wǎng)發(fā)展報(bào)告2018
- WordPress Web Application Development
- 網(wǎng)絡(luò)基礎(chǔ)與網(wǎng)絡(luò)管理項(xiàng)目化教程
- 網(wǎng)絡(luò)環(huán)境中基于用戶視角的信息質(zhì)量評(píng)價(jià)研究
- 人人都該都懂的互聯(lián)網(wǎng)思維
- Getting Started with nopCommerce
- 移動(dòng)物聯(lián)網(wǎng):商業(yè)模式+案例分析+應(yīng)用實(shí)戰(zhàn)
- 圖神經(jīng)網(wǎng)絡(luò)前沿
- 網(wǎng)絡(luò)安全之道