Documentation
¶
Index ¶
- func InstrumentDuration(handlerName string) func(http.Handler) http.Handler
- func InstrumentInflight(handler http.Handler) http.Handler
- func InstrumentResponseSize(handlerName string) func(http.Handler) http.Handler
- func ReturnESJSON(w http.ResponseWriter, code int, data any)
- func Server(validator gopherpolicy.Validator, storageInterface storage.Storage) error
- type EventList
- type MetricsAPI
- type V1API
- type VersionAPI
- type VersionData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstrumentDuration ¶
InstrumentDuration wraps a handler with request duration metrics
func InstrumentInflight ¶
InstrumentInflight wraps a handler with inflight request metrics
func InstrumentResponseSize ¶
InstrumentResponseSize wraps a handler with response size metrics
func ReturnESJSON ¶
func ReturnESJSON(w http.ResponseWriter, code int, data any)
ReturnESJSON is a custom response helper that preserves the storage backend URL formatting. This is needed because OpenSearch requires literal & characters in URLs, but Go's JSON marshaler escapes them as \u0026.
Example:
events := []Event{...}
ReturnESJSON(w, http.StatusOK, map[string]any{
"events": events,
"total": len(events),
})
Types ¶
type EventList ¶
type EventList struct {
NextURL string `json:"next,omitempty"`
PrevURL string `json:"previous,omitempty"`
Events []*hermes.ListEvent `json:"events"`
Total int `json:"total"`
}
EventList is the model for JSON returned by the ListEvents API call
type MetricsAPI ¶
type MetricsAPI struct{}
MetricsAPI handles Prometheus metrics
func (*MetricsAPI) AddTo ¶
func (api *MetricsAPI) AddTo(r *mux.Router)
AddTo implements httpapi.API interface
type V1API ¶
type V1API struct {
// contains filtered or unexported fields
}
V1API implements the v1 API endpoints using httpapi patterns
func NewV1API ¶
func NewV1API(validator gopherpolicy.Validator, storageInterface storage.Storage) *V1API
NewV1API creates a new V1API instance with the provided validator and storage.
Example:
validator := gopherpolicy.NewValidator(enforcer, logger) storage := opensearch.NewStorage(config) api := NewV1API(validator, storage)
func (*V1API) VersionData ¶
func (api *V1API) VersionData() VersionData
VersionData returns the version data for this API
type VersionAPI ¶
type VersionAPI struct {
// contains filtered or unexported fields
}
VersionAPI handles version advertisement
func NewVersionAPI ¶
func NewVersionAPI(v1VersionData VersionData) *VersionAPI
NewVersionAPI creates a version API instance
func (*VersionAPI) AddTo ¶
func (api *VersionAPI) AddTo(r *mux.Router)
AddTo implements httpapi.API interface
type VersionData ¶
type VersionData struct {
Status string `json:"status"`
ID string `json:"id"`
Links []versionLinkData `json:"links"`
}
VersionData is used by version advertisement handlers.