Skip to content

cognizone/vinz-clortho

Repository files navigation

Vinz Clortho

A lightweight replacement for Zuul when using spring boot 2.7+

Get started

In your code just add the @EnableVinzClorthoProxy annotation on any @Configuration class. Then setup the routing configuration like this:

cognizone:
  vinz:
    routes:
      - name: firstRoute   # just a name, make it unique, nothing else special here 
        path: /proxy/route1/**  # the path on your server (if you use a servlet context path, this will be the part after the context path) 
        url: http://example.com/route1  # The destination url to proxy to
      - name: secondRoute
        path: /proxy/route2/**
        url: http://example.com/route2
        headers:
          response-set:
            - key: Access-Control-Allow-Headers
              value: "*"
              filter: "#{[request].getHeader('Origin') != null}"

That's it, you're all set.

What's supported

Altering the body of the Request

Create a spring bean implementing cogni.zone.vinzclortho.BodyEditor. If such a bean exists, it will be called with the original HttpRequest and content body as an InputStream, so you can change the content of the request body. The new body has to be returned as a org.apache.http.HttpEntity object.

Validate if a Request is allowed

Create a spring bean implementing cogni.zone.vinzclortho.RequestValidator. If such a bean exists, it will be called with the original request information. If you return a non-null value, that value with be used to send the response and no proxying will be done.

HTTP methods

At the moment following HTTP methods are supported: GET, POST, PUT, DELETE

Headers

Follow headers will be passed from the original request:

  • Accept
  • Accept-Language
  • Content-Type
  • User-Agent

After the proxied request, following response headers will be sent back to the client:

  • Content-Type

In the example above Access-Control-Allow-Headers: * will be added to the response of secondRoute in case the filter matches. The filter should be a spel expression that returns a boolean. In this example (#{[request].getHeader('Origin') != null}) the header will be set if the original request contains an Origin header.