GO Web Services

From bibbleWiki
Revision as of 07:58, 25 August 2021 by Iwiseman (talk | contribs) (Created page with "=Handling Requests= *Handle a handler to handle requests matching a pattern *HandleFunc a function to handle requests matching a pattern <syntaxhighlight lang="go"> type foo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Handling Requests

  • Handle a handler to handle requests matching a pattern
  • HandleFunc a function to handle requests matching a pattern
type fooHandler struct {
  Message string
}

func (f *fooHandler) ServeHTTP(w http.ResponseWrite, r *http.Request) {
  w.Write([]byte(f.Message))
}


func main() {
  http.Handle("/foo", &fooHandler{Message: "hello Word"})
}