// getTimestampHandler returns a timestamp.json given a GUN func getSnapshot(ctx context.Context, w http.ResponseWriter, logger ctxu.Logger, store storage.MetaStore, gun string) error { cryptoServiceVal := ctx.Value("cryptoService") cryptoService, ok := cryptoServiceVal.(signed.CryptoService) if !ok { return errors.ErrNoCryptoService.WithDetail(nil) } out, err := snapshot.GetOrCreateSnapshot(gun, store, cryptoService) if err != nil { switch err.(type) { case *storage.ErrNoKey, storage.ErrNotFound: logger.Error("404 GET snapshot") return errors.ErrMetadataNotFound.WithDetail(nil) default: logger.Error("500 GET snapshot") return errors.ErrUnknown.WithDetail(err) } } logger.Debug("200 GET snapshot") w.Write(out) return nil }