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

Running the code

We can run the preceding code as a standalone program. Name the preceding program basicHandler.go. Store it anywhere you wish to, then run it using the following command:

go run basicHandler.go

Now fire up a shell or browser to see the server in action. Here, I use the CURL request:

curl -X GET http://localhost:8000/hello

The response is:

hello, world

Go has a different concept for handling request and response. We used the io library to write to the response. For web development, we can use a template to automatically fill in the details. Go's internal URL handlers use a ServeMux multiplexer.

主站蜘蛛池模板: 文成县| 梅州市| 霍州市| 沙洋县| 苍南县| 施秉县| 马龙县| 邵武市| 马龙县| 阿拉尔市| 微博| 吴川市| 鲁甸县| 双辽市| 甘孜县| 沽源县| 浦县| 瑞丽市| 邮箱| 连南| 台南县| 公主岭市| 宝丰县| 华阴市| 根河市| 延庆县| 广南县| 区。| 琼中| 墨脱县| 四川省| 英德市| 汉川市| 正镶白旗| 丰镇市| 石家庄市| 密云县| 郑州市| 简阳市| 卫辉市| 凉山|