package http import ( "encoding/json" "fmt" "net/http" "strings" "github.com/gtsteffaniak/filebrowser/backend/files" "github.com/gtsteffaniak/filebrowser/backend/users" _ "github.com/gtsteffaniak/filebrowser/backend/swagger/docs" ) func publicShareHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) { file, ok := d.raw.(files.ExtendedFileInfo) if !ok { return http.StatusInternalServerError, fmt.Errorf("failed to assert type files.FileInfo") } file.Path = strings.TrimPrefix(file.Path, files.RootPaths["default"]) return renderJSON(w, r, file) } func publicUserGetHandler(w http.ResponseWriter, r *http.Request) { // Call the actual handler logic here (e.g., renderJSON, etc.) // You may need to replace `fn` with the actual handler logic. status, err := renderJSON(w, r, users.PublicUser) if err != nil { http.Error(w, http.StatusText(status), status) } } // health godoc // @Summary Health Check // @Schemes // @Description Returns the health status of the API. // @Tags Health // @Accept json // @Produce json // @Success 200 {object} HttpResponse "successful health check response" // @Router /health [get] func healthHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") response := HttpResponse{Message: "ok"} // Create response with status "ok" err := json.NewEncoder(w).Encode(response) // Encode the response into JSON if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) } }