This commit is contained in:
Sotig
2026-03-21 15:35:50 +02:00
commit 07cd9ebac9
10 changed files with 259 additions and 0 deletions

42
cmd/actions.go Normal file
View File

@@ -0,0 +1,42 @@
package main
import "net/http"
func actions(mux *http.ServeMux) {
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
})
mux.HandleFunc("/analyze-fff", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
})
mux.HandleFunc("/analyze-sla", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
})
}

28
cmd/main.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"fmt"
"net/http"
"os"
"golang.org/x/net/http2"
)
func main() {
// Your code here
mux := http.NewServeMux()
svr := &http.Server{
Addr: fmt.Sprintf("%s:%s", os.Getenv("HOST"), os.Getenv("PORT")),
Handler: mux,
}
http2.ConfigureServer(svr, nil)
actions(mux) // Register actions with the multiplexer
fmt.Printf("Starting server on %s:%s\n", os.Getenv("HOST"), os.Getenv("PORT"))
err := svr.ListenAndServe()
if err != nil {
panic(err)
}
}