1 // This file is safe to edit. Once it exists it will not be overwritten
9 errors "github.com/go-openapi/errors"
10 runtime "github.com/go-openapi/runtime"
11 middleware "github.com/go-openapi/runtime/middleware"
13 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations"
14 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/common"
15 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/policy"
16 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/query"
17 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/report"
20 //go:generate swagger generate server --target ../../pkg --name XappFramework --spec ../../api/xapp_rest_api.yaml --exclude-main
22 func configureFlags(api *operations.XappFrameworkAPI) {
23 // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
26 func configureAPI(api *operations.XappFrameworkAPI) http.Handler {
27 // configure the api here
28 api.ServeError = errors.ServeError
30 // Set your custom logger if needed. Default one is log.Printf
31 // Expected interface func(string, ...interface{})
34 // api.Logger = log.Printf
36 api.JSONConsumer = runtime.JSONConsumer()
38 api.JSONProducer = runtime.JSONProducer()
40 if api.CommonUnsubscribeHandler == nil {
41 api.CommonUnsubscribeHandler = common.UnsubscribeHandlerFunc(func(params common.UnsubscribeParams) middleware.Responder {
42 return middleware.NotImplemented("operation common.Unsubscribe has not yet been implemented")
45 if api.QueryGetAllSubscriptionsHandler == nil {
46 api.QueryGetAllSubscriptionsHandler = query.GetAllSubscriptionsHandlerFunc(func(params query.GetAllSubscriptionsParams) middleware.Responder {
47 return middleware.NotImplemented("operation query.GetAllSubscriptions has not yet been implemented")
50 if api.PolicySubscribePolicyHandler == nil {
51 api.PolicySubscribePolicyHandler = policy.SubscribePolicyHandlerFunc(func(params policy.SubscribePolicyParams) middleware.Responder {
52 return middleware.NotImplemented("operation policy.SubscribePolicy has not yet been implemented")
55 if api.ReportSubscribeReportHandler == nil {
56 api.ReportSubscribeReportHandler = report.SubscribeReportHandlerFunc(func(params report.SubscribeReportParams) middleware.Responder {
57 return middleware.NotImplemented("operation report.SubscribeReport has not yet been implemented")
61 api.ServerShutdown = func() {}
63 return setupGlobalMiddleware(api.Serve(setupMiddlewares))
66 // The TLS configuration before HTTPS server starts.
67 func configureTLS(tlsConfig *tls.Config) {
68 // Make all necessary changes to the TLS configuration here.
71 // As soon as server is initialized but not run yet, this function will be called.
72 // If you need to modify a config, store server instance to stop it individually later, this is the place.
73 // This function can be called multiple times, depending on the number of serving schemes.
74 // scheme value will be set accordingly: "http", "https" or "unix"
75 func configureServer(s *http.Server, scheme, addr string) {
78 // The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
79 // The middleware executes after routing but before authentication, binding and validation
80 func setupMiddlewares(handler http.Handler) http.Handler {
84 // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
85 // So this is a good place to plug in a panic handling middleware, logging and metrics
86 func setupGlobalMiddleware(handler http.Handler) http.Handler {