- Building RESTful Web services with Go
- Naren Yellavula
- 107字
- 2021-07-02 20:14:07
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.
推薦閱讀
- EJB 3.1從入門到精通
- 物聯(lián)網(wǎng)(IoT)基礎(chǔ):網(wǎng)絡(luò)技術(shù)+協(xié)議+用例
- 物聯(lián)網(wǎng)檢驗(yàn)檢測(cè)技術(shù)
- Django 2 by Example
- Web Application Development with R Using Shiny
- 計(jì)算機(jī)網(wǎng)絡(luò)與數(shù)據(jù)通信
- 計(jì)算機(jī)網(wǎng)絡(luò)安全實(shí)訓(xùn)教程(第二版)
- 智慧光網(wǎng)絡(luò):關(guān)鍵技術(shù)、應(yīng)用實(shí)踐和未來(lái)演進(jìn)
- 物聯(lián)網(wǎng)之霧:基于霧計(jì)算的智能硬件快速反應(yīng)與安全控制
- 網(wǎng)絡(luò)安全應(yīng)急響應(yīng)技術(shù)實(shí)戰(zhàn)
- 搶占下一個(gè)智能風(fēng)口:移動(dòng)物聯(lián)網(wǎng)
- 網(wǎng)絡(luò)環(huán)境中基于用戶視角的信息質(zhì)量評(píng)價(jià)研究
- 高級(jí)網(wǎng)絡(luò)技術(shù)
- 轉(zhuǎn)化:提升網(wǎng)站流量和轉(zhuǎn)化率的技巧
- 網(wǎng)絡(luò)空間全球治理觀察