Skip to content

Instantly share code, notes, and snippets.

@shijuvar
Created January 20, 2016 10:07
Show Gist options
  • Save shijuvar/393624931b3691d831a2 to your computer and use it in GitHub Desktop.
Save shijuvar/393624931b3691d831a2 to your computer and use it in GitHub Desktop.
HTTP Server with custom HTTP Handler
package main
import (
"fmt"
"log"
"net/http"
)
type indexHandler struct {
}
func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to Go Web Development")
}
func main() {
mux := http.NewServeMux()
index := &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