Support for prefixed Orchard Controller API URLs (#355)

* Support for prefixed Orchard Controller API URLs

* Fix Swagger UI

* Remove spurious "fmt" import

* Use url.URL in order to correctly calculate API path for Swagger UI
This commit is contained in:
Nikolay Edigaryev
2025-10-06 20:04:47 +04:00
committed by GitHub
parent 6d23548d81
commit af221cf3c1
7 changed files with 85 additions and 16 deletions
+8
View File
@@ -24,6 +24,7 @@ import (
var ErrRunFailed = errors.New("failed to run controller")
var address string
var apiPrefix string
var addressSSH string
var addressPprof string
var debug bool
@@ -50,6 +51,9 @@ func newRunCommand() *cobra.Command {
cmd.Flags().StringVarP(&address, "listen", "l", fmt.Sprintf(":%s", port),
"address to listen on")
cmd.Flags().StringVar(&apiPrefix, "api-prefix", "",
"prefix to prepend to all Orchard Controller API endpoints; useful when exposing Orchard Controller "+
"behind an HTTP proxy together with other services")
cmd.Flags().StringVar(&addressSSH, "listen-ssh", "",
"address for the built-in SSH server to listen on (e.g. \":6122\")")
cmd.Flags().StringVar(&addressPprof, "listen-pprof", "",
@@ -144,6 +148,10 @@ func runController(cmd *cobra.Command, args []string) (err error) {
controller.WithLogger(logger),
}
if apiPrefix != "" {
controllerOpts = append(controllerOpts, controller.WithAPIPrefix(apiPrefix))
}
var controllerCert tls.Certificate
if !noTLS {