Skip to content

feat: add RSS 2.0 feed generation support#240

Closed
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh:add-rss-feed
Closed

feat: add RSS 2.0 feed generation support#240
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh:add-rss-feed

Conversation

@gumruyanzh
Copy link

Summary

  • Adds jetzig.Rss module for generating valid RSS 2.0 XML feeds
  • Provides Channel and Item structs with proper XML escaping
  • Exports via jetzig.Rss so views can use request.renderText() to serve feeds
  • Includes demo view (demo/src/app/views/feed.zig) showing the pattern

Design

Rather than middleware, this takes the utility-module approach: views generate RSS XML using the builder and return it via request.renderText() with content_type = "application/rss+xml". This is consistent with how the framework already handles custom content types (see render_text.zig demo).

Example usage

const jetzig = @import("jetzig");

pub fn index(request: *jetzig.Request) !jetzig.View {
    const channel = jetzig.Rss.Channel{
        .title = "My Blog",
        .link = "https://example.com",
        .description = "Latest posts",
        .items = &.{
            .{ .title = "First Post", .link = "https://example.com/first", .description = "Hello" },
        },
    };
    const xml = try jetzig.Rss.generate(request.allocator, channel);
    request.response.content_type = "application/rss+xml";
    return request.renderText(xml, .ok);
}

Test plan

  • zig build succeeds
  • zig build test --summary all - all 75 tests pass
  • zig test src/jetzig/Rss.zig - 3/3 RSS unit tests pass (minimal feed, items, XML escaping)

Closes #36

🤖 Generated with Claude Code

Add jetzig.Rss module for generating valid RSS 2.0 XML feeds.

- RSS builder with Channel and Item structs for structured feed data
- XML escaping for special characters (&, <, >, ", ')
- Optional fields: language, pubDate, lastBuildDate, guid, author
- Exported as jetzig.Rss for use in views via request.renderText()
- Demo view showing RSS feed endpoint usage
- Unit tests for minimal feed, items, and XML escaping

Usage in a view:
  const channel = jetzig.Rss.Channel{ .title = "My Blog", ... };
  const xml = try jetzig.Rss.generate(request.allocator, channel);
  request.response.content_type = "application/rss+xml";
  return request.renderText(xml, .ok);

Closes #36

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gumruyanzh gumruyanzh closed this by deleting the head repository Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rss feed

1 participant