gofeed icon indicating copy to clipboard operation
gofeed copied to clipboard

v2: Implement ParseOptions foundation for parser API

Open mmcdole opened this issue 7 months ago • 0 comments

Overview

This PR implements the foundation for ParseOptions as specified in #244. It establishes the basic structure and API changes needed for v2, with some features left for future implementation.

What's Implemented

Core ParseOptions Structure

  • Created ParseOptions struct with all fields from the RFC
  • Added RequestOptions sub-struct for HTTP configuration
  • Added StrictnessOptions for parsing behavior control

API Updates

  • All parsers now accept *ParseOptions parameter (can be nil)
  • Changed ParseURL to context-first: ParseURL(ctx, url, opts)
  • Removed ParseURLWithContext - context is now always required
  • Updated translators to accept ParseOptions for future extensibility

Basic Features

  • MaxItems limiting - implemented at parse level (not translation)
  • KeepOriginalFeed - stores format-specific feed in Feed.OriginalFeed
  • UserAgent and AuthConfig support in ParseURL
  • Client and Timeout configuration

Left for Future PRs

  • Conditional requests (IfNoneMatch, IfModifiedSince) - see #247
  • HTTP response metadata collection - see #247
  • ParseDates toggle
  • StrictnessOptions implementation

Breaking Changes

  1. All Parse methods now require *ParseOptions:

    // Old
    feed, err := parser.Parse(reader)
    
    // New
    feed, err := parser.Parse(reader, nil)  // nil for defaults
    
  2. ParseURL is now context-first:

    // Old
    feed, err := parser.ParseURL(url)
    feed, err := parser.ParseURLWithContext(url, ctx)
    
    // New
    feed, err := parser.ParseURL(context.Background(), url, nil)
    

Testing

All existing tests have been updated and are passing. The API is ready for use, though some ParseOptions fields are not yet implemented.

Closes #244

mmcdole avatar May 26 '25 21:05 mmcdole