GO Web Services: Difference between revisions
Jump to navigation
Jump to search
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..." |
|||
Line 10: | Line 10: | ||
func (f *fooHandler) ServeHTTP(w http.ResponseWrite, r *http.Request) { | func (f *fooHandler) ServeHTTP(w http.ResponseWrite, r *http.Request) { | ||
w.Write([]byte(f.Message)) | w.Write( []byte(f.Message) ) | ||
} | } | ||
Revision as of 07:59, 25 August 2021
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"})
}