Created
March 24, 2019 18:36
-
-
Save akash-gautam/4b0487f5a44dd0f35c5247da64c73ade to your computer and use it in GitHub Desktop.
maion.go file for sample application used in ci/cd for k8s using circleci & helm blog
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" | |
"net/http" | |
"log" | |
"github.com/gorilla/mux" | |
) | |
type Message struct { | |
Msg string | |
} | |
func helloWorldJSON(w http.ResponseWriter, r *http.Request) { | |
m := Message{"Hello World"} | |
response, _ := json.Marshal(m) | |
w.Header().Set("Content-Type", "application/json") | |
w.WriteHeader(http.StatusOK) | |
w.Write(response) | |
} | |
func main() { | |
r := mux.NewRouter() | |
r.HandleFunc("/hello", helloWorldJSON).Methods("GET") | |
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