Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef183ab1ce | ||
|
|
d2e57f0af4 | ||
|
|
40a9bb4724 |
@@ -1 +1,2 @@
|
|||||||
.env
|
.env
|
||||||
|
.dockerenv
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ echo "Doing build"
|
|||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/arm64 \
|
--platform linux/arm64 \
|
||||||
--push \
|
--push \
|
||||||
-t gitea.coupxd.com/cody/hello-fastapi:latest \
|
-t gitea.coupxd.com/cody/go-weather:latest \
|
||||||
.
|
.
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ type Reading struct {
|
|||||||
FetchedAt time.Time `json:"fetched_at"`
|
FetchedAt time.Time `json:"fetched_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HealthResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
func getEnv(key string) string {
|
func getEnv(key string) string {
|
||||||
val := os.Getenv(key)
|
val := os.Getenv(key)
|
||||||
if val == "" {
|
if val == "" {
|
||||||
@@ -243,6 +247,19 @@ func main() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// GET /health
|
||||||
|
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// TODO: Check if database is ready as well
|
||||||
|
if r.Method != http.MethodGet {
|
||||||
|
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
okStatus := HealthResponse{Status: "ok"}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(okStatus)
|
||||||
|
})
|
||||||
|
|
||||||
// GET /weather/history?city=London&limit=10
|
// GET /weather/history?city=London&limit=10
|
||||||
http.HandleFunc("/weather/history", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/weather/history", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodGet {
|
if r.Method != http.MethodGet {
|
||||||
|
|||||||
Reference in New Issue
Block a user