Skip to content

Instantly share code, notes, and snippets.

@shijuvar
Created January 20, 2016 11:25
Show Gist options
  • Save shijuvar/8f9b19d7649f18381b7f to your computer and use it in GitHub Desktop.
Save shijuvar/8f9b19d7649f18381b7f to your computer and use it in GitHub Desktop.
Using HandlerFunc type as the HTTP handler
package main
import (
"fmt"
"log"
"net/http"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to Go Web Development")
}
func main() {
mux := http.NewServeMux()
index := http.HandlerFunc(indexHandler)
mux.Handle("/", index)
log.Println("Listening...")
http.ListenAndServe(":8080", mux)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment