Skip to content

Is there a way for a Callout to inspect the method and path on the request? #245

@DinoChiesa

Description

@DinoChiesa

I am looking through the Java callout examples. I don't see a way for the Callout to see the method or path on the request.

Envoyproxy has "pseudo headers" of :path and :method, but I have not been able to retrieve values for them.

BTW is this really the simplest way to retrieve a header value?

  private static String getHeader(HttpHeaders headers, String headerName) {
    return headers.getHeaders().getHeadersList().stream()
        .filter(header -> headerName.equalsIgnoreCase(header.getKey()))
        .map(header -> new String(header.getRawValue().toByteArray(), StandardCharsets.UTF_8))
        .findFirst()
        .orElse(null);
  }

EDIT Check that. I had configured the service extension to receive only a specific set of headers. (Check this doc) . When I removed the forwardHeaders element, my Callout got all the headers, including the pseudo headers.

Still have a remaining question ... is that ^^ the correct way to get a single header?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions