Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/ebuild/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (s *serverRunner) runAPI(cmd *cobra.Command, args []string) {
s.opts.HTTPBindAddress,
s.opts.HTTPBindPort,
),
s.opts,
)
if err != nil {
fmt.Printf("failed to start API server: %s", err)
Expand Down
1 change: 1 addition & 0 deletions config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type CloudbuildOpts struct {
LogLevel LogLevel `mapstructure:"log-level"`
HTTPBindAddress net.IP `mapstructure:"listen-ip"`
HTTPBindPort uint16 `mapstructure:"port"`
TrustedPlatform string `mapstructure:"platform"`

// Database options:
DatabaseDSN string `mapstructure:"database-dsn"`
Expand Down
10 changes: 7 additions & 3 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/edgetx/cloudbuild/artifactory"
"github.com/edgetx/cloudbuild/auth"
"github.com/edgetx/cloudbuild/config"
"github.com/edgetx/cloudbuild/processor"
"github.com/edgetx/cloudbuild/targets"
"github.com/gin-contrib/static"
Expand Down Expand Up @@ -226,14 +227,17 @@ func debugRoutes(method, path, _ string, _ int) {
}).Debugf("endpoint")
}

func (app *Application) Start(listen string) error {
func (app *Application) Start(listen string, opts *config.CloudbuildOpts) error {
gin.DebugPrintRouteFunc = debugRoutes
router := gin.New()
router.Use(ginlogrus.Logger(log.New()))
router.Use(gin.Recovery())

// this should be a config parameter (in case behind CF)
router.SetTrustedProxies(nil) //nolint:errcheck
if opts.TrustedPlatform == "cloudflare" {
router.TrustedPlatform = gin.PlatformCloudflare
} else {
router.SetTrustedProxies(nil) //nolint:errcheck
}

// later this should server static content (dashboard app?)
router.Use(static.ServeRoot("/", staticContentDir))
Expand Down