add initial frontend
This commit is contained in:
@@ -44,6 +44,11 @@ type TestResponse struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type LatestTemperatureResponse struct {
|
||||
Temp int `json:"temp"`
|
||||
}
|
||||
|
||||
|
||||
func getEnv(key string) string {
|
||||
val := os.Getenv(key)
|
||||
if val == "" {
|
||||
@@ -264,6 +269,19 @@ func main() {
|
||||
json.NewEncoder(w).Encode(okStatus)
|
||||
})
|
||||
|
||||
// GET /latest-temperature
|
||||
http.HandleFunc("/latest-temperature", func(w http.ResponseWriter, r *http.Request) {
|
||||
// testing api integration
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
okStatus := LatestTemperatureResponse{Temp: 69}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(okStatus)
|
||||
})
|
||||
|
||||
// GET /test
|
||||
http.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
|
||||
// testing deployment pipeline
|
||||
|
||||
Reference in New Issue
Block a user