Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Getting User-Agent Header in Sightly?


Level 3

Hello all!

I need to do some workarounds for Microsoft products, and to do that I need to know the User-Agent in slightly, and do something different in the template if the User-Agent is 'ms-office'.

I've never been able to figure out how to use methods on the 'request' global object that require parameters.

I'm trying to do something like this:

${request.header @ name='User-Agent' }

but, that's not working.

I've seen examples like this:


...but that requestParameterMap method doesn't require any returns an array, which is getting sub-selected in the expression.

There isn't a method on the 'request' object that returns all of the headers and their values that I can use this way.

I can create a whole java/js backer file just to get this one variable in this one case, but that seems way overkill compared to just passing in the name of the header that I need.  Especially since the request object is already in scope?



0 Replies