In GoLang there are several ways you can do..
- By using http.HandleFunc
 - Interface implemantations http.Handler in the struct, and then using in the function http.Handler()
 - Create multiplexer by using struct http.ServeMux
 - Etc.
 
But in the series, we just used http.HandleFunc, okay so lets do it.
http.HandleFunc()
as explained briefly in the previous chapter, the http.HandlerFunc function is used for route / endpoint registration and its handler.
- First step, create main.go and import package net/http
 
- Next, create function main() and add closure handlerIndex, and then used it closure as handler from new 2route registation, that is / and /index.
 
- Still in function main(), add the new Route /data with handler is anonymous function.
 
- Last step, run the server
 
- So, Run & Test
 
Grats, hope your enjoy it.
    
Top comments (0)