A simple look at some basic ways of getting HTTP routing of GET requests in Go.
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.

16 lines
243 B

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. )
  7. func main() {
  8. http.HandleFunc("/hello", HelloHTTP)
  9. log.Fatal(http.ListenAndServe(":8080", nil))
  10. }
  11. func HelloHTTP(w http.ResponseWriter, req *http.Request) {
  12. fmt.Fprint(w, "Hello HTTP")
  13. }