- 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.
推薦閱讀
- 數(shù)據(jù)通信網(wǎng)絡(luò)實(shí)踐:基礎(chǔ)知識(shí)與交換機(jī)技術(shù)
- OpenLayers Cookbook
- Building RESTful Web Services with Spring 5(Second Edition)
- 物聯(lián)網(wǎng)與無(wú)線傳感器網(wǎng)絡(luò)
- 電力物聯(lián)網(wǎng)工程技術(shù)原理與應(yīng)用
- Android UI Design
- 網(wǎng)絡(luò)AI+:2030后的未來(lái)網(wǎng)絡(luò)
- 高級(jí)網(wǎng)絡(luò)技術(shù)
- Microsoft Power Platform Enterprise Architecture
- 數(shù)據(jù)血緣分析原理與實(shí)踐
- 云計(jì)算技術(shù)與標(biāo)準(zhǔn)化
- Laravel Application Development Cookbook
- 視聽變革:廣電的新媒體戰(zhàn)略
- LiveCode Mobile Development Beginner's Guide
- Hands-On Full Stack Web Development with Aurelia