Skip to content

Commit 61946c8

Browse files
author
Marvin
committed
'Add French Greeting Endpoint to API'
1 parent 83153ba commit 61946c8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ func main() {
2020
}
2121
})
2222

23+
mux.HandleFunc("/french", func(w http.ResponseWriter, r *http.Request) {
24+
fmt.Printf("got /french request from %s\n", r.RemoteAddr)
25+
w.Header().Set("Content-Type", "application/json")
26+
_, err := w.Write([]byte(frenchGreeting()))
27+
if err != nil {
28+
panic(err)
29+
}
30+
})
31+
2332
c := cors.New(cors.Options{
2433
AllowedOrigins: []string{
2534
"http://greetings.kylepenfound.com",
@@ -44,3 +53,8 @@ func greeting() string {
4453
greeting := "Greetings Daggernauts!"
4554
return fmt.Sprintf("{\"greeting\":\"%s\"}", greeting)
4655
}
56+
57+
func frenchGreeting() string {
58+
frenchGreeting := "Salutations Daggernauts !"
59+
return fmt.Sprintf("{\"greeting\":\"%s\"}", frenchGreeting)
60+
}

0 commit comments

Comments
 (0)