- Hands-On RESTful Web Services with Go
- Naren Yellavula
- 167字
- 2021-06-24 17:04:26
Understanding httprouter – a lightweight HTTP router
httprouter, as the name suggests, routes the HTTP requests to particular handlers. httprouter is a well-known package in Go for creating simple routers with an elegant API. The developers coming from the Python/Django community are very familiar with a full-blown URL dispatcher in the Django framework. httprouter provides similar features:
- Allows variables in the route paths
- Matches the REST methods (GET, POST, PUT, and so on)
- No compromise of performance
We are going to discuss these qualities in more detail in the following section. Before that, there are a few noteworthy points that make httprouter an even better URL router:
- httprouter plays well with the in-built http.Handler
- httprouter explicitly says that a request can only match to one route or no route
- The router's design encourages building sensible, hierarchical RESTful APIs
- You can build simple and efficient static file servers
In the next section, we see the installation of httprouter and its basic usage.
推薦閱讀
- Oracle 11g從入門到精通(第2版) (軟件開發(fā)視頻大講堂)
- 算法基礎(chǔ):打開程序設(shè)計(jì)之門
- Java Web及其框架技術(shù)
- Mastering PHP Design Patterns
- Hands-On C++ Game Animation Programming
- C++程序設(shè)計(jì)基礎(chǔ)教程
- Python數(shù)據(jù)挖掘與機(jī)器學(xué)習(xí)實(shí)戰(zhàn)
- Hands-On Automation Testing with Java for Beginners
- 快人一步:系統(tǒng)性能提高之道
- ASP.NET程序開發(fā)范例寶典
- Visual Basic程序設(shè)計(jì)(第三版)
- Python開發(fā)基礎(chǔ)
- Windows Phone 8 Game Development
- PhoneGap 4 Mobile Application Development Cookbook
- C#程序設(shè)計(jì)基礎(chǔ)入門教程