/** * Explicit constructor. * * @param okapiUrl * @param vertx * @param headers may be null */ public OkapiClient(String okapiUrl, Vertx vertx, Map<String, String> headers) { init(vertx); setOkapiUrl(okapiUrl); setHeaders(headers); respHeaders = null; }
/** * Constructor from a vert.x ctx. That ctx contains all the headers we need. * * @param ctx */ public OkapiClient(RoutingContext ctx) { init(ctx.vertx()); this.okapiUrl = ctx.request().getHeader(XOkapiHeaders.URL); if (this.okapiUrl != null) { this.okapiUrl = okapiUrl.replaceAll("/+$", ""); // no trailing slash } for (String hdr : ctx.request().headers().names()) { if (hdr.startsWith(XOkapiHeaders.PREFIX) || hdr.startsWith("Accept")) { String hv = ctx.request().getHeader(hdr); headers.put(hdr, hv); if (hdr.equals(XOkapiHeaders.REQUEST_ID)) { reqId = hv; } } } }