Skip to content

Instantly share code, notes, and snippets.

@brachi-wernick
Created February 24, 2020 21:36
Show Gist options
  • Save brachi-wernick/ea8358882bff8509d59fe3d8f0445b25 to your computer and use it in GitHub Desktop.
Save brachi-wernick/ea8358882bff8509d59fe3d8f0445b25 to your computer and use it in GitHub Desktop.
GoJi hello world
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