All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.up.uca.rs.argument.CookieFiller Maven / Gradle / Ivy

The newest version!
package io.vertx.up.uca.rs.argument;

import io.vertx.core.http.Cookie;
import io.vertx.ext.web.RoutingContext;
import io.vertx.up.uca.rs.Filler;

import java.util.Objects;

/**
 * 「Co」JSR311 for .@CookieParam
 *
 * This `Filler` is for cookie attributes extracting
 *
 * @author Lang
 */
public class CookieFiller implements Filler {
    @Override
    public Object apply(final String name,
                        final Class paramType,
                        final RoutingContext context) {
        if (Cookie.class.isAssignableFrom(paramType)) {
            /*
             * Declared `Cookie` directly
             */
            return context.request().getCookie(name);
        } else {
            /*
             * Declared other type
             */
            final Cookie cookie = context.request().getCookie(name);
            return Objects.isNull(cookie) ? null : cookie.getValue();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy