package main import ( "log" "net/http" ) // Server base struct type Server struct { port string } func (s *Server) serve() { mux := http.NewServeMux() mux.Handle("/", s.handle()) mux.Handle("/articles", getAllArticles()) log.Print("Listening on", s.port) log.Fatal(http.ListenAndServe(s.port, mux)) } func (s *Server) handle() http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(string("Hello World"))) } return http.HandlerFunc(fn) }