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

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.

主站蜘蛛池模板: 包头市| 青田县| 东阳市| 三江| 广水市| 重庆市| 大新县| 大足县| 蒙阴县| 肇东市| 青岛市| 惠州市| 舟山市| 岢岚县| 合江县| 壶关县| 容城县| 临猗县| 石渠县| 大石桥市| 祁门县| 城步| 苍山县| 喀喇| 溧水县| 高唐县| 梁河县| 方城县| 聂拉木县| 小金县| 民丰县| 永州市| 商河县| 桑植县| 道孚县| 沂南县| 兴业县| 隆昌县| 襄汾县| 奎屯市| 彩票|