jeudi 17 juin 2021

Parse Caller IP from Request in Apache Camel

I have a REST-API using Spring and Apache Camel. When a specific request is made, I'll get an Exchange (Apache Camel) object which provides the Messageobject.

Reading from it like this: e.getIn() provides me the request information available. I've read from other posts, that I could either access the client's IP by checking the headers as described here:

org.apache.camel.Processor get source ip address

Although nothing like this is existing, so I am stuck. Is there even a way to get the client's IP from this request?

How I parse the request

def parseAndValidateRequest(): Processor =
    (e: Exchange) => {
      implicit val exchange: Exchange = e
      val request = for {
        from <- requiredParameter[String]("from")
        to <- requiredParameter[String]("to")
        ip <- requiredParameter[???)
      } yield
        Request(...

Thanks for any inputs!




Aucun commentaire:

Enregistrer un commentaire