We just updated the empty files in one single go and started running the server. Let me now explain each and every piece of the file main.go:
- Imported a few packages. github.com/narenaryan/romanNumerals is the data service we created before.
- net/http is the core package we used to handle an HTTP request through its HandleFunc function. That function's arguments are http.Request and http.ResponseWriter. Those two deal with the request and response of an HTTP request.
- r.URL.Path is the URL path of the HTTP request. For the CURL Request one, it is /roman_number/5. We are splitting this path and using the second argument as a resource and the third argument as a value to get the Roman numeral. The Split function is in ...