Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
steviebps committed Oct 9, 2021
1 parent 7a2f940 commit 14d7fc7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions examples/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ import (
realm "github.com/steviebps/realm/pkg"
)

func handler(w http.ResponseWriter, r *http.Request) {
message := realm.StringValue("message", "DEFAULT")
w.Write([]byte(message))
}

func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", handler)

realm.SetVersion("v1.0.0")

Expand All @@ -31,7 +24,14 @@ func main() {
log.Fatal(err)
}

port := realm.Float64Value("port", 3000)
port, _ := realm.Float64Value("port", 3000)

mux := http.NewServeMux()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
message, _ := realm.StringValue("message", "DEFAULT")
w.Write([]byte(message))
})

log.Println("Listening on :", port)
err := http.ListenAndServe(fmt.Sprintf(":%d", int(port)), mux)
Expand Down

0 comments on commit 14d7fc7

Please sign in to comment.