- 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.
推薦閱讀
- JavaScript百煉成仙
- Learn to Create WordPress Themes by Building 5 Projects
- Selenium Design Patterns and Best Practices
- Practical DevOps
- Internet of Things with Intel Galileo
- PostgreSQL Replication(Second Edition)
- 從Excel到Python:用Python輕松處理Excel數(shù)據(jù)(第2版)
- Scala Reactive Programming
- C++從入門(mén)到精通(第5版)
- Hands-On GUI Programming with C++ and Qt5
- Learning Hadoop 2
- C++程序設(shè)計(jì)
- Mastering ASP.NET Core 2.0
- MySQL數(shù)據(jù)庫(kù)應(yīng)用實(shí)戰(zhàn)教程(慕課版)
- 虛擬現(xiàn)實(shí)建模與編程(SketchUp+OSG開(kāi)發(fā)技術(shù))