Documentation ¶
Index ¶
- func GetOranReqErrFunc() func(w http.ResponseWriter, r *http.Request, err error)
- func GetOranRespErrFunc() func(w http.ResponseWriter, r *http.Request, err error)
- func GracefulShutdown(srv *http.Server) error
- func NotFoundFunc() func(w http.ResponseWriter, r *http.Request)
- func ValidateCallbackURL(callback string) error
- type FilterAdapter
- func (a *FilterAdapter) EnforceRequiredFields(projector *search.Projector, r *http.Request) error
- func (a *FilterAdapter) Error(w http.ResponseWriter, details string, status int) error
- func (a *FilterAdapter) EvaluateProjector(projector *search.Projector, object any) (map[string]any, error)
- func (a *FilterAdapter) EvaluateSelector(selector *search.Selector, object any) (bool, error)
- func (a *FilterAdapter) ParseFields(fields ...string) ([]search.Path, error)
- func (a *FilterAdapter) ParseFilter(query string) (*search.Selector, error)
- type FilterResponseInterceptor
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOranReqErrFunc ¶
func GetOranReqErrFunc() func(w http.ResponseWriter, r *http.Request, err error)
GetOranReqErrFunc override default validation errors to allow for O-RAN specific struct
func GetOranRespErrFunc ¶
func GetOranRespErrFunc() func(w http.ResponseWriter, r *http.Request, err error)
GetOranRespErrFunc override default internal server error to allow for O-RAN specific struct
func GracefulShutdown ¶
GracefulShutdown allow graceful shutdown with timeout
func NotFoundFunc ¶
func NotFoundFunc() func(w http.ResponseWriter, r *http.Request)
NotFoundFunc is used to override the default 404 response which is a text only reply so that we can respond with the required JSON body.
func ValidateCallbackURL ¶
ValidateCallbackURL ensures that the URL used in subscription callback meets our requirements
Types ¶
type FilterAdapter ¶
type FilterAdapter struct {
// contains filtered or unexported fields
}
FilterAdapter is an abstraction that wraps the search projector/selector functionality so that these objects can be created once at server initialization time and re-used in the ResponseFilter middleware.
func NewFilterAdapter ¶
NewFilterAdapter creates a new filter adapter to be passed to a ResponseFilter
func (*FilterAdapter) EnforceRequiredFields ¶
EnforceRequiredFields ensures that required fields are always included and never excluded
func (*FilterAdapter) Error ¶
func (a *FilterAdapter) Error(w http.ResponseWriter, details string, status int) error
Error sends an error using the proper ORAN format
func (*FilterAdapter) EvaluateProjector ¶
func (a *FilterAdapter) EvaluateProjector(projector *search.Projector, object any) (map[string]any, error)
EvaluateProjector delegates the function of evaluating the set of field projections to the projector evaluator.
func (*FilterAdapter) EvaluateSelector ¶
EvaluateSelector delegates the function of evaluating the set of search selectors to the selector evaluator.
func (*FilterAdapter) ParseFields ¶
func (a *FilterAdapter) ParseFields(fields ...string) ([]search.Path, error)
ParseFields delegates the function of parsing the include/exclude fields to the path parser.
func (*FilterAdapter) ParseFilter ¶
func (a *FilterAdapter) ParseFilter(query string) (*search.Selector, error)
ParseFilter delegates the function of parsing the filter fields to the selector parser.
type FilterResponseInterceptor ¶
type FilterResponseInterceptor struct {
// contains filtered or unexported fields
}
FilterResponseInterceptor implements the http.ResponseWriter interface so that it can be used to intercept all operations intended for the request's ResponseWriter into a local buffer. At the end of the request the local buffer is evaluated against the selector/projector built from the 'fields', 'exclude_fields', and 'filter' query parameters and transforms the response object accordingly.
func (*FilterResponseInterceptor) Flush ¶
func (i *FilterResponseInterceptor) Flush(r *http.Request) error
Flush is invoked at the end of the request so that the response can be transformed/filtered if necessary. Both the selector (filtering) and projector (transformations) are applied to any operations that have a 200 status code and contain valid JSON for either a list or object representation.
func (*FilterResponseInterceptor) Header ¶
func (i *FilterResponseInterceptor) Header() http.Header
Header is a simple pass-through to the original http.ResponseWriter's Header method
func (*FilterResponseInterceptor) Write ¶
func (i *FilterResponseInterceptor) Write(data []byte) (int, error)
Write intercepts the bytes intended for the underlying http.ResponseWriter and stores them locally for later processing.
func (*FilterResponseInterceptor) WriteHeader ¶
func (i *FilterResponseInterceptor) WriteHeader(statusCode int)
WriteHeader intercepts the response's status code and stores it locally. It is not passed through in case processing in this interceptor fails, and we need to override the response code.
type Middleware ¶
func LogDuration ¶
func LogDuration() Middleware
LogDuration log time taken to complete a request. TODO: This is just get started with middleware but should be replaced with something that's more suitable for production i.e OpenTelemetry https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/examples/prometheus/main.go
func OpenAPIValidation ¶
func OpenAPIValidation(swagger *openapi3.T) Middleware
OpenAPIValidation to validate all incoming requests as specified in the spec
func ResponseFilter ¶
func ResponseFilter(adapter *FilterAdapter) Middleware
ResponseFilter intercepts the response body and removes fields that are not required.