MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / handleListTutorials

Method handleListTutorials

internal/server/tutorials.go:219–237  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

217// catalog could not be fetched and no earlier copy exists, and the client then
218// links to getpad.dev/learn.
219func (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
239var errTutorialPosterOrigin = errors.New("tutorials: poster is not on getpad.dev")
240

Callers

nothing calls this directly

Calls 4

tutorialCatalogNowMethod · 0.95
writeErrorFunction · 0.85
writeJSONFunction · 0.85
sameOriginEntriesFunction · 0.85

Tested by

no test coverage detected