handleListTutorials: GET /tutorials. Cloud only (404 on a self-hosted server). {available, paths, tutorials, demos}; available=false when the catalog could not be fetched and no earlier copy exists, and the client then links to getpad.dev/learn.
(w http.ResponseWriter, r *http.Request)
| 217 | // catalog could not be fetched and no earlier copy exists, and the client then |
| 218 | // links to getpad.dev/learn. |
| 219 | func (s *Server) handleListTutorials(w http.ResponseWriter, r *http.Request) { |
| 220 | if !s.cloudMode { |
| 221 | writeError(w, http.StatusNotFound, "not_found", "Not found") |
| 222 | return |
| 223 | } |
| 224 | cat := s.tutorialCatalogNow(r.Context()) |
| 225 | if cat == nil { |
| 226 | writeJSON(w, http.StatusOK, map[string]any{ |
| 227 | "available": false, "paths": []tutorialPath{}, "tutorials": []tutorialEntry{}, "demos": []tutorialEntry{}, |
| 228 | }) |
| 229 | return |
| 230 | } |
| 231 | writeJSON(w, http.StatusOK, map[string]any{ |
| 232 | "available": true, |
| 233 | "paths": cat.Paths, |
| 234 | "tutorials": sameOriginEntries(cat.Tutorials), |
| 235 | "demos": sameOriginEntries(cat.Demos), |
| 236 | }) |
| 237 | } |
| 238 | |
| 239 | var errTutorialPosterOrigin = errors.New("tutorials: poster is not on getpad.dev") |
| 240 |
nothing calls this directly
no test coverage detected