-
Notifications
You must be signed in to change notification settings - Fork 96
[WIP] feat(version): add server version endpoint and client version display #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package main | |
| import ( | ||
| "context" | ||
| "crypto/tls" | ||
| "encoding/json" | ||
| "net" | ||
| "net/http" | ||
| "os" | ||
|
|
@@ -264,6 +265,12 @@ func main() { | |
| anthropicHandler := anthropic.NewHandler(log, schedulerHTTP, nil, modelManager) | ||
| router.Handle(anthropic.APIPrefix+"/", anthropicHandler) | ||
|
|
||
| // Register /version endpoint | ||
| router.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { | ||
| w.Header().Set("Content-Type", "application/json") | ||
| _ = json.NewEncoder(w).Encode(map[string]string{"version": Version}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error returned by if err := json.NewEncoder(w).Encode(map[string]string{"version": Version}); err != nil {
log.Warnf("failed to write version response: %v", err)
} |
||
| }) | ||
|
|
||
| // Register root handler LAST - it will only catch exact "/" requests that don't match other patterns | ||
| router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
| // Only respond to exact root path | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package main | ||
|
|
||
| var Version = "dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logic for displaying server information in the
versioncommand has a couple of issues. First, it incorrectly reports the engine as(not reachable)when running in standalone mode (whendesktopClientisnil). The engine kind is a client-side property and should be available. Second, the logic is a bit repetitive and can be simplified for better readability and correctness.I suggest refactoring this section to always display the engine kind and to determine the server version more concisely.