Switched to Feedburner

I've switched my feeds at my BadMagicNumber blog to be published via FeedBurner. There should be no disruption to your normal programming, although I think some aggregators will show some non-new items as new.

I switched the feeds over using a simple Servlet Filter. If anyone wants to do the same, here's the code. This works for blojsom, but you might need to modify it slightly for your own setup.


public class FeedBurnerRedirectFilter implements Filter {
	private String redirectURL;
	
	public void init(FilterConfig config) throws ServletException {
		redirectURL = config.getInitParameter("redirectURL");		
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
						throws IOException, ServletException {
		String flavor = request.getParameter("flavor"); 
		
		if ("atom".equals(flavor) || "rss".equals(flavor) 
				|| "rss2".equals(flavor) || "rdf".equals(flavor) ) {			
			HttpServletRequest httpRequest = (HttpServletRequest) request;			
			HttpServletResponse httpResponse = (HttpServletResponse) response;
			
			String userAgent = httpRequest.getHeader("User-Agent");
			if (userAgent != null && userAgent.indexOf("FeedBurner") < 0) {
				/// redirect if not feedburner
				httpResponse.sendRedirect(redirectURL);
				return;				
			}
			
		}		
		chain.doFilter(request, response);		
	}

	public void destroy() {
		
	}
}

2 thoughts on “Switched to Feedburner

  1. That would mean you had access to your Apache config, which I did not…

Leave a Reply

Your email address will not be published. Required fields are marked *