forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CookieParamExtractor.java
26 lines (20 loc) · 975 Bytes
/
CookieParamExtractor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package org.jboss.resteasy.reactive.server.core.parameters;
import javax.ws.rs.core.Cookie;
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;
public class CookieParamExtractor implements ParameterExtractor {
private final String name;
private final String parameterTypeName;
public CookieParamExtractor(String name, String parameterTypeName) {
this.name = name;
this.parameterTypeName = parameterTypeName;
}
@Override
public Object extractParameter(ResteasyReactiveRequestContext context) {
if (Cookie.class.getName().equals(parameterTypeName)) {
// we need to make sure we preserve the name because otherwise CookieHeaderDelegate will not be able to convert back to Cookie
Cookie cookie = context.getHttpHeaders().getCookies().get(name);
return cookie != null ? cookie.toString() : null;
}
return context.getCookieParameter(name);
}
}