Skip to content

Commit

Permalink
Host parameter for server
Browse files Browse the repository at this point in the history
This is a stopgap measure until we get the Host header processing
working for the server
  • Loading branch information
stalehd committed Apr 9, 2023
1 parent f1f8435 commit 678f14c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmd/pax/cmd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *serverCmd) Execute([]string) error {
GRPCListenAddr: opt.GRPCListenAddr,
SpanToken: opt.Token,
SpanCollectionID: opt.CollectionID,
HTTPHost: opt.HTTPHost,
})

c := make(chan os.Signal, 2)
Expand Down
16 changes: 8 additions & 8 deletions cmd/pax/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
)

var opt struct {
DB string `long:"db" default:"pax.db" description:"pax database" required:"yes"`
HTTPListenAddr string `long:"http" default:":4500" description:"HTTP listen address" required:"yes"`
GRPCListenAddr string `long:"grpc" default:":4501" description:"gRPC listen address" required:"yes"`
Token string `long:"token" env:"SPAN_API_TOKEN" description:"Span API Token" required:"yes"`
CollectionID string `long:"collection" description:"Span Collection ID for PAX counters" default:"17dlb1hl0l800a"`

Server serverCmd `command:"server" description:"start server"`
Fetch fetchCmd `command:"fetch" description:"fetch historical data"`
DB string `long:"db" default:"pax.db" description:"pax database" required:"yes"`
HTTPListenAddr string `long:"http" default:":4500" description:"HTTP listen address" required:"yes"`
GRPCListenAddr string `long:"grpc" default:":4501" description:"gRPC listen address" required:"yes"`
Token string `long:"token" env:"SPAN_API_TOKEN" description:"Span API Token" required:"yes"`
CollectionID string `long:"collection" description:"Span Collection ID for PAX counters" default:"17dlb1hl0l800a"`
HTTPHost string `long:"host" default:"http://localhost:4500" description:"HTTP (external) URL" required:"yes"`
Server serverCmd `command:"server" description:"start server"`
Fetch fetchCmd `command:"fetch" description:"fetch historical data"`
}

func main() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (s *Server) startHTTP() error {
httpMux := http.NewServeMux()

// TODO: Use the proper external address here. Either "http://localhost:4500" (dev) or https://pax.lab5e.com (production)

gotileserver.RegisterHandler(httpMux, "http://localhost:4500")
log.Printf("Registering map tile server with external address %s", s.config.HTTPHost)
gotileserver.RegisterHandler(httpMux, s.config.HTTPHost)
mux.PathPrefix("/map").Handler(httpMux)
mux.PathPrefix("/").Handler(http.FileServer(http.FS(frontendFS)))

Expand Down
1 change: 1 addition & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Config struct {
GRPCListenAddr string
SpanToken string
SpanCollectionID string
HTTPHost string
}

// Create and start server instance.
Expand Down

0 comments on commit 678f14c

Please sign in to comment.