Skip to content

Commit

Permalink
feat: add server version number
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 12, 2022
1 parent 8ed3fa0 commit 3d6c951
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/charm/client"
"github.com/charmbracelet/charm/cmd"
"github.com/charmbracelet/charm/server"
"github.com/charmbracelet/charm/ui"
"github.com/charmbracelet/charm/ui/common"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -62,6 +63,7 @@ func init() {
}
}
rootCmd.Version = Version
server.Version = Version

rootCmd.AddCommand(
cmd.BioCmd,
Expand Down
1 change: 1 addition & 0 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func NewHTTPServer(cfg *Config) (*HTTPServer, error) {
healthMux := http.NewServeMux()
// No auth health check endpoint
healthMux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Version", Version)
fmt.Fprintf(w, "We live!")
}))
health := &http.Server{
Expand Down
6 changes: 6 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import (
"golang.org/x/sync/errgroup"
)

var (
// Version is the version of the Charm Cloud server. This is set at build
// time by main.go.
Version = ""
)

// Config is the configuration for the Charm server.
type Config struct {
BindAddr string `env:"CHARM_SERVER_BIND_ADDRESS" envDefault:""`
Expand Down

0 comments on commit 3d6c951

Please sign in to comment.