Add models
[ric-plt/xapp-frame.git] / pkg / restapi / configure_xapp_framework.go
1 // This file is safe to edit. Once it exists it will not be overwritten
2
3 package restapi
4
5 import (
6         "crypto/tls"
7         "net/http"
8
9         errors "github.com/go-openapi/errors"
10         runtime "github.com/go-openapi/runtime"
11         middleware "github.com/go-openapi/runtime/middleware"
12
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/control"
16         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/policy"
17         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/report"
18 )
19
20 //go:generate swagger generate server --target ../../pkg --name XappFramework --spec ../../api/xapp_rest_api.yaml --exclude-main
21
22 func configureFlags(api *operations.XappFrameworkAPI) {
23         // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
24 }
25
26 func configureAPI(api *operations.XappFrameworkAPI) http.Handler {
27         // configure the api here
28         api.ServeError = errors.ServeError
29
30         // Set your custom logger if needed. Default one is log.Printf
31         // Expected interface func(string, ...interface{})
32         //
33         // Example:
34         // api.Logger = log.Printf
35
36         api.JSONConsumer = runtime.JSONConsumer()
37
38         api.JSONProducer = runtime.JSONProducer()
39
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")
43                 })
44         }
45         if api.ControlSubscribeControlHandler == nil {
46                 api.ControlSubscribeControlHandler = control.SubscribeControlHandlerFunc(func(params control.SubscribeControlParams) middleware.Responder {
47                         return middleware.NotImplemented("operation control.SubscribeControl has not yet been implemented")
48                 })
49         }
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")
53                 })
54         }
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")
58                 })
59         }
60
61         api.ServerShutdown = func() {}
62
63         return setupGlobalMiddleware(api.Serve(setupMiddlewares))
64 }
65
66 // The TLS configuration before HTTPS server starts.
67 func configureTLS(tlsConfig *tls.Config) {
68         // Make all necessary changes to the TLS configuration here.
69 }
70
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) {
76 }
77
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 {
81         return handler
82 }
83
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 {
87         return handler
88 }