Created
February 24, 2020 21:36
-
-
Save brachi-wernick/ea8358882bff8509d59fe3d8f0445b25 to your computer and use it in GitHub Desktop.
GoJi hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"math/rand" | |
"net/http" | |
"time" | |
"goji.io" | |
"goji.io/pat" | |
"strconv" | |
) | |
func main() { | |
mux := goji.NewMux() | |
mux.HandleFunc(pat.Get("/hello/:name"), hello) | |
http.ListenAndServe(":8099", mux) | |
} | |
func hello(w http.ResponseWriter, r *http.Request) { | |
name := pat.Param(r, "name") | |
fmt.Fprintf(w, "Hello, %s!", name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment