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

Method fetchTutorialPoster

internal/server/tutorials.go:289–302  ·  view source on GitHub ↗
(ctx context.Context, src string)

Source from the content-addressed store, hash-verified

287}
288
289func (s *Server) fetchTutorialPoster(ctx context.Context, src string) ([]byte, string, error) {
290 if !strings.HasPrefix(src, tutorialsPosterOrigin) {
291 return nil, "", errTutorialPosterOrigin
292 }
293 data, ctype, err := s.fetchTutorialBytes(ctx, src, tutorialsPosterMaxSize)
294 if err != nil {
295 return nil, "", err
296 }
297 switch ctype = strings.ToLower(strings.TrimSpace(strings.Split(ctype, ";")[0])); ctype {
298 case "image/jpeg", "image/png", "image/webp":
299 return data, ctype, nil
300 }
301 return nil, "", fmt.Errorf("tutorials: poster content type %q", ctype)
302}

Callers 1

handleTutorialPosterMethod · 0.95

Calls 1

fetchTutorialBytesMethod · 0.95

Tested by

no test coverage detected