Skip to content

Commit

Permalink
Add a ping endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
llemeurfr committed Dec 31, 2024
1 parent 3d9eee4 commit aadb3b8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lcpserver/api/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,8 @@ func downloadFile(url string, targetFilePath string) error {

return nil
}

// Ping is a simple health check
func Ping(w http.ResponseWriter, r *http.Request, s Server) {
w.WriteHeader(http.StatusOK)
}
3 changes: 3 additions & 0 deletions lcpserver/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func New(bindAddr string, readonly bool, idx *index.Index, st *storage.Store, ls
// Route.Subrouter: http://www.gorillatoolkit.org/pkg/mux#Route.Subrouter
// Router.StrictSlash: http://www.gorillatoolkit.org/pkg/mux#Router.StrictSlash

// Ping endpoint
s.handleFunc(sr.R, "/ping", apilcp.Ping).Methods("GET")

// Serve static resources from a configurable directory.
// This is used when lcpencrypt sends encrypted resources and cover images to an fs storage,
// and we want this http server to provide such resources to the outside world (e.g. PubStore).
Expand Down
5 changes: 5 additions & 0 deletions lsdserver/api/license_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,3 +1132,8 @@ func fillLicenseStatus(ls *licensestatuses.LicenseStatus, s Server) error {

return err
}

// Ping is a simple health check
func Ping(w http.ResponseWriter, r *http.Request, s Server) {
w.WriteHeader(http.StatusOK)
}
3 changes: 3 additions & 0 deletions lsdserver/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func New(bindAddr string, readonly bool, goofyMode bool, lst *licensestatuses.Li
// Route.Subrouter: http://www.gorillatoolkit.org/pkg/mux#Route.Subrouter
// Router.StrictSlash: http://www.gorillatoolkit.org/pkg/mux#Router.StrictSlash

// Ping endpoint
s.handleFunc(sr.R, "/ping", apilsd.Ping).Methods("GET")

licenseRoutesPathPrefix := "/licenses"
licenseRoutes := sr.R.PathPrefix(licenseRoutesPathPrefix).Subrouter().StrictSlash(false)

Expand Down

0 comments on commit aadb3b8

Please sign in to comment.