官术网_书友最值得收藏!

Running the code

We can run the program directly using the run command:

go run customMux.go

 Now, let us fire two CURL commands and see the output:

curl -X GET http://localhost:8000/randomFloat
curl -X GET http://localhost:8000/randomInt

The responses will be:

0.6046602879796196
87

Your response may change due to the random number generator.

We saw how we can create a URL router with basic Go constructs. Now we are going to look at a few popular URL routing frameworks that are widely used by the Go community for their API servers.

主站蜘蛛池模板: 彩票| 郎溪县| 马龙县| 泸溪县| 连江县| 那坡县| 左权县| 长泰县| 故城县| 揭东县| 金秀| 石首市| 长顺县| 岱山县| 井研县| 玉龙| 建平县| 樟树市| 云浮市| 新化县| 海丰县| 昆山市| 浙江省| 郴州市| 上思县| 东安县| 寿光市| 绩溪县| 大化| 乌鲁木齐县| 洞头县| 综艺| 克拉玛依市| 永昌县| 德格县| 台安县| 富民县| 汕头市| 林口县| 怀集县| 新干县|