- Hands-On RESTful Web Services with Go
- Naren Yellavula
- 155字
- 2021-06-24 17:04:27
Fundamentals of gorilla/mux
The gorilla/mux package primarily helps to create routers, similar to httprouter. The difference between both is the attachment of a handler function to a given URL. If we observe, the gorilla/mux way of attaching a handler is similar to that of basic ServeMux. Unlike httprouter, gorilla/mux wraps all the information of an HTTP request into a single request object.
The three important tools provided in the gorilla/mux API are:
- The mux.NewRouter method
- The *http.Request object
- The *http.ResponseWriter object
The NewRouter method creates a new router object. That object basically maps a route to a function handler. gorilla/mux passes a modified *http.Request and *http.ResponseWriter object to the function handler. These special objects have lots of additional information about headers, path parameters, request body, and query parameters. Let us explain how to define and use different routers in gorilla/mux with two common types:
- Path-based matching
- Query-based matching
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- Designing Machine Learning Systems with Python
- JavaScript 從入門到項目實踐(超值版)
- 深度學習經典案例解析:基于MATLAB
- OpenCV for Secret Agents
- PHP 編程從入門到實踐
- Scratch 3.0少兒編程與邏輯思維訓練
- 機械工程師Python編程:入門、實戰與進階
- 零基礎學Java(第4版)
- 琢石成器:Windows環境下32位匯編語言程序設計
- Mastering Apache Maven 3
- Learning JavaScript Data Structures and Algorithms
- 零基礎入門學習Python(第2版)
- Lighttpd源碼分析
- OpenCV 4計算機視覺項目實戰(原書第2版)