protected Object cookie ( Type type , String name ) { return parameter ( type , name , new Function < String , Object > ( ) { public Object apply ( String name ) { Cookie [ ] cookies = context . request ( ) . getCookies ( ) ; if ( cookies != null ) { for ( Cookie cookie : cookies ) { if ( cookie . getName ( ) . equals ( name ) ) { return cookie . getValue ( ) ; } } } return null ; } } , new Function < String , Collection < Object > > ( ) { public Collection < Object > apply ( String name ) { HttpServletRequest request = context . request ( ) ; Map < String , Object > map = new TreeMap < String , Object > ( ) ; Cookie [ ] cookies = request . getCookies ( ) ; if ( cookies != null ) { for ( Cookie cookie : cookies ) { String key = cookie . getName ( ) ; if ( key . startsWith ( name + "[" ) ) { map . put ( key , cookie . getValue ( ) ) ; } } } return ( map . isEmpty ( ) ) ? null : map . values ( ) ; } } ) ; }
Returns the Web endpoint method parameter from cookie in the HTTP request .