File size: 658 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package web

import (
	"fmt"
	"net/http"
)

// DisabledEndpointMessage returns a consistent message for locked endpoint families.
func DisabledEndpointMessage(feature, setting string) string {
	return fmt.Sprintf("%s endpoint is disabled; enable %s in config to use this endpoint", feature, setting)
}

// DisabledEndpointHandler returns a handler that reports a feature gate lock.
func DisabledEndpointHandler(feature, setting, code string) http.HandlerFunc {
	return func(w http.ResponseWriter, _ *http.Request) {
		ErrorCode(w, http.StatusForbidden, code, DisabledEndpointMessage(feature, setting), false, map[string]any{
			"setting": setting,
		})
	}
}