Introduction
This challenge aims to test your ability to write a basic HTTP server using the net/http
package in Golang.
This challenge aims to test your ability to write a basic HTTP server using the net/http
package in Golang.
You are required to write a simple HTTP server that can handle two routes: /hello
and /headers
. The /hello
route should return a simple "hello" response, while the /headers
route should return all the HTTP request headers.
net/http
package./hello
route should return a "hello" response./headers
route should return all the HTTP request headers.8090
.## Run the server in the background.
$ go run http-servers.go &
## Access the `/hello` route.
$ curl localhost:8090/hello
hello
In this challenge, you were required to write a simple HTTP server that can handle two routes: /hello
and /headers
. You learned how to use the net/http
package to write handlers for each route and register them on the server. Finally, you learned how to start the server and listen for incoming requests.