ReloadHandler returns a handler for POST /internal/reload that evicts a host from the pool and Redis caches. Requires X-Registry-Reload-Secret header to match reloadSecret. Query param: host (the host to evict).
(poolCache *PoolCache, redisCache *RedisCache, reloadSecret string)
| 113 | // Requires X-Registry-Reload-Secret header to match reloadSecret. |
| 114 | // Query param: host (the host to evict). |
| 115 | func ReloadHandler(poolCache *PoolCache, redisCache *RedisCache, reloadSecret string) http.HandlerFunc { |
| 116 | return func(w http.ResponseWriter, r *http.Request) { |
| 117 | if r.Method != http.MethodPost { |
| 118 | http.Error(w, "method not allowed", http.StatusMethodNotAllowed) |
| 119 | return |
| 120 | } |
| 121 | if reloadSecret != "" && !secureCompare(r.Header.Get(reloadSecretHeader), reloadSecret) { |
| 122 | http.Error(w, "unauthorized", http.StatusUnauthorized) |
| 123 | return |
| 124 | } |
| 125 | host := r.URL.Query().Get("host") |
| 126 | if host == "" { |
| 127 | http.Error(w, "host query param required", http.StatusBadRequest) |
| 128 | return |
| 129 | } |
| 130 | if poolCache != nil { |
| 131 | poolCache.Evict(host) |
| 132 | } |
| 133 | if redisCache != nil { |
| 134 | redisCache.Evict(host) |
| 135 | } |
| 136 | w.Header().Set("Content-Type", "application/json") |
| 137 | w.WriteHeader(http.StatusOK) |
| 138 | _, _ = w.Write([]byte(`{"ok":true}`)) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | // Historical note: a /api/v1/internal/migrate-tenant handler lived here |
| 143 | // until the legacy-import control plane was redrawn. It let the manager |