Skip to content

Instantly share code, notes, and snippets.

@akash-gautam
Created March 24, 2019 18:36
Show Gist options
  • Save akash-gautam/4b0487f5a44dd0f35c5247da64c73ade to your computer and use it in GitHub Desktop.
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
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