Initial commit

This commit is contained in:
2026-11-16 20:49:40 +02:00
commit eed5a36dd4
32 changed files with 621 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"time"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]string{"status": "ok", "service": "api"})
})
// Placeholder only: registration/authentication is not implemented.
mux.HandleFunc("POST /api/v1/auth/register", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "registration not implemented", http.StatusNotImplemented)
})
addr := os.Getenv("API_ADDR")
if addr == "" {
addr = ":8080"
}
srv := &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second}
log.Printf("API listening on %s", addr)
log.Fatal(srv.ListenAndServe())
}
+18
View File
@@ -0,0 +1,18 @@
package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestHealthEndpoint(t *testing.T) {
req := httptest.NewRequest("GET", "/healthz", nil)
rec := httptest.NewRecorder()
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) })
mux.ServeHTTP(rec, req)
if rec.Code != 200 {
t.Fatalf("want 200, got %d", rec.Code)
}
}
+21
View File
@@ -0,0 +1,21 @@
package main
import (
"log"
"net/http"
"time"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok\n"))
})
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "key directory not implemented", http.StatusNotImplemented)
})
srv := &http.Server{Addr: ":8082", Handler: mux, ReadHeaderTimeout: 5 * time.Second}
log.Printf("keyserver listening on %s", srv.Addr)
log.Fatal(srv.ListenAndServe())
}
+21
View File
@@ -0,0 +1,21 @@
package main
import (
"log"
"net/http"
"time"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok\n"))
})
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "push dispatcher not implemented", http.StatusNotImplemented)
})
srv := &http.Server{Addr: ":8083", Handler: mux, ReadHeaderTimeout: 5 * time.Second}
log.Printf("push service listening on %s", srv.Addr)
log.Fatal(srv.ListenAndServe())
}
+28
View File
@@ -0,0 +1,28 @@
package main
import (
"log"
"net/http"
"os"
"time"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok\n"))
})
mux.HandleFunc("GET /ws/v1/signaling", func(w http.ResponseWriter, r *http.Request) {
// Deliberately disabled until authentication, authorization, message limits,
// replay protection and routing are implemented.
http.Error(w, "signaling is not enabled in scaffold", http.StatusNotImplemented)
})
addr := os.Getenv("SIGNALING_ADDR")
if addr == "" {
addr = ":8081"
}
srv := &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second}
log.Printf("signaling service listening on %s", addr)
log.Fatal(srv.ListenAndServe())
}