post image January 6, 2022 | 1 min Read

Go HandlerFunc()

package main

import (
	"io"
	"net/http"
)


func dogs(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "This is the web about dogs!\n")
}


func cats(w http.ResponseWriter, r *http.Request)  {
	io.WriteString(w, "This is the web about cats!\n")
}

func main() {

	http.Handle("/dogs/", http.HandlerFunc(dogs))
	http.Handle("/cats",  http.HandlerFunc(cats))

	http.ListenAndServe(":8080", nil)

}

author image

Jan Toth

I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …

comments powered by Disqus