Advertisement
Guest User

Untitled

a guest
Oct 7th, 2021
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.42 KB | None | 0 0
  1. func startHttp(port int) {
  2.     fmt.Println("Starting server on port: " + strconv.Itoa(port) + "!")
  3.     for root, data := range handlers {
  4.         fmt.Println(root, data)
  5.         http.HandleFunc(root, func(writer http.ResponseWriter, request *http.Request) {
  6.             fmt.Println(root, data)
  7.             fmt.Fprint(writer, string(data))
  8.         })
  9.     }
  10.     err := http.ListenAndServe(":"+strconv.Itoa(port), nil)
  11.     if err != nil {
  12.         log.Fatal(err)
  13.         os.Exit(1)
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement