mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
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:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -46,6 +47,7 @@ const (
|
||||
type Controller struct {
|
||||
dataDir *DataDir
|
||||
listenAddr string
|
||||
apiPrefix string
|
||||
tlsConfig *tls.Config
|
||||
listener net.Listener
|
||||
httpServer *http.Server
|
||||
@@ -262,11 +264,17 @@ func (controller *Controller) Run(ctx context.Context) error {
|
||||
func (controller *Controller) Address() string {
|
||||
hostPort := strings.ReplaceAll(controller.listener.Addr().String(), "[::]", "127.0.0.1")
|
||||
|
||||
if controller.tlsConfig != nil {
|
||||
return fmt.Sprintf("https://%s", hostPort)
|
||||
url := url.URL{
|
||||
Scheme: "http",
|
||||
Host: hostPort,
|
||||
Path: controller.apiPrefix,
|
||||
}
|
||||
|
||||
return fmt.Sprintf("http://%s", hostPort)
|
||||
if controller.tlsConfig != nil {
|
||||
url.Scheme = "https"
|
||||
}
|
||||
|
||||
return url.String()
|
||||
}
|
||||
|
||||
func (controller *Controller) SSHAddress() (string, bool) {
|
||||
|
||||
Reference in New Issue
Block a user