forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that JAX-RS Cookie parameter type is usable in Resource methods
Fixes: quarkusio#28453
- Loading branch information
Showing
4 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
11 changes: 10 additions & 1 deletion
11
...rc/main/java/org/jboss/resteasy/reactive/server/core/parameters/CookieParamExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,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) { | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters