You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
806 B

  1. // hello.go ported for appengine
  2. //
  3. // this differs from the standard hello.go example in two ways: appengine
  4. // already provides an http server for you, obviating the need for the
  5. // ListenAndServe call (with associated logging), and the package must not be
  6. // called main (appengine reserves package 'main' for the underlying program).
  7. package patexample
  8. import (
  9. "io"
  10. "net/http"
  11. "github.com/bmizerany/pat"
  12. )
  13. // hello world, the web server
  14. func HelloServer(w http.ResponseWriter, req *http.Request) {
  15. io.WriteString(w, "hello, "+req.URL.Query().Get(":name")+"!\n")
  16. }
  17. func init() {
  18. m := pat.New()
  19. m.Get("/hello/:name", http.HandlerFunc(HelloServer))
  20. // Register this pat with the default serve mux so that other packages
  21. // may also be exported. (i.e. /debug/pprof/*)
  22. http.Handle("/", m)
  23. }