Skip to content

Instantly share code, notes, and snippets.

@mlabouardy
Created August 9, 2017 09:44
Show Gist options
  • Save mlabouardy/0050935bdc811c17eecb6bb0b06b2518 to your computer and use it in GitHub Desktop.
Save mlabouardy/0050935bdc811c17eecb6bb0b06b2518 to your computer and use it in GitHub Desktop.
http server in golang
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
func HomeEndpoint(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello from mlabouardy :)")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/", HomeEndpoint)
if err := http.ListenAndServe(":8080", r); err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment