mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 16:08:05 +00:00
31 lines
628 B
Go
31 lines
628 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
type Health struct {
|
|
Status string `json:"status"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
func greeting(name string) string {
|
|
if name == "" {
|
|
name = "world"
|
|
}
|
|
return fmt.Sprintf("Hello, %s!", name)
|
|
}
|
|
|
|
func main() {
|
|
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Fprintln(w, greeting(r.URL.Query().Get("name")))
|
|
})
|
|
// FIXME: health check should report database connectivity
|
|
http.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
|
|
fmt.Fprintln(w, `{"status":"ok"}`)
|
|
})
|
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
}
|