mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
feat(multiplayer): add degraded admission mode
This commit is contained in:
@@ -127,6 +127,7 @@ type Service struct {
|
||||
RankedProfileProvider RankedProfileProvider
|
||||
TierPolicy domain.TierPolicy
|
||||
RateLimiter *RateLimiter
|
||||
Admission AdmissionController
|
||||
// Log receives a credential-safe structured event for lifecycle-relevant
|
||||
// reads and mutations. Nil
|
||||
// is a valid, silent no-op -- every call site must stay optional so
|
||||
@@ -213,6 +214,16 @@ func (s *Service) Handler() http.Handler {
|
||||
mux.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
if s.Admission != nil {
|
||||
admissionHandler := handler
|
||||
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if operation := admissionOperation(r.URL.Path, r.Method); operation != "" && !s.Admission.Allow(operation) {
|
||||
writeError(w, http.StatusServiceUnavailable, "service_degraded")
|
||||
return
|
||||
}
|
||||
admissionHandler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
if s.Metrics == nil {
|
||||
return handler
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user