MCPcopy Create free account
hub / github.com/rilldata/rill / versionHandler

Method versionHandler

cli/pkg/local/server.go:994–1021  ·  view source on GitHub ↗

versionHandler servers the current and latest version of the Rill CLI.

()

Source from the content-addressed store, hash-verified

992
993// versionHandler servers the current and latest version of the Rill CLI.
994func (s *Server) versionHandler() http.Handler {
995 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
996 // Get the latest version available
997 latestVersion, err := s.app.ch.LatestVersion(r.Context())
998 if err != nil {
999 s.logger.Warn("error finding latest version", zap.Error(err))
1000 }
1001
1002 inf := &versionResponse{
1003 CurrentVersion: s.app.ch.Version.Number,
1004 LatestVersion: latestVersion,
1005 }
1006
1007 data, err := json.Marshal(inf)
1008 if err != nil {
1009 w.WriteHeader(http.StatusBadRequest)
1010 return
1011 }
1012
1013 w.Header().Add("Content-Type", "application/json")
1014
1015 _, err = w.Write(data)
1016 if err != nil {
1017 http.Error(w, fmt.Sprintf("failed to write response data: %s", err), http.StatusInternalServerError)
1018 return
1019 }
1020 })
1021}
1022
1023// nameConflictRetryErrClassifier classifies name already exists errors as retryable, works for both github repo and project name
1024type nameConflictRetryErrClassifier struct{}

Callers 1

RegisterHandlersMethod · 0.95

Calls 6

LatestVersionMethod · 0.80
WriteHeaderMethod · 0.80
ContextMethod · 0.65
AddMethod · 0.65
ErrorMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected