Module for parsing user agent?

The problem I’m having:

I have a need to:

  • Parse the User-Agent to extract the browser name & browser version.
  • Compare that version to a list contained in a JSON file (the list is essentially browser name & major version).
  • Then if the version is greater than the JSON file version I want to route my static file requests to root A, if not then I want to route the file requests to root B. (essentially, I think I want to do a rewrite of the url if the version is great than those in my JSON file.)

I have been searching this community and reading through the modules and the documentation and I am thinking I may need to develop my own module (e.g. http.matchers.browser_version). Before I do that I wanted to check with the collective intelligence here to make sure there is not a solution that is eluding me?

  • Is there a set of features that could be cobbled together to solve my problem?
  • Any help appreciated!!

Thanks much!

1 Like

It might be possible to do with map using regexp then expression matchers for the version number comparison… but honestly, I think you’d have an easier time writing a custom matcher module like you suggested. User-Agent parsing is not simple unfortunately, because each browser lies for legacy backwards compatibility :grimacing:

1 Like

@francislavoie, thanks for the quick response!

Yes, I was thinking that IFF there was a module that may have implemented useragent parsing I could have possibly glued it up. But without that, I think I am pretty much required to develop the go module.


This topic was automatically closed after 30 days. New replies are no longer allowed.