spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.49k stars 3.3k forks source link

Question migrate Apache httpd to spring gateway #3349

Open mailsanchu opened 4 months ago

mailsanchu commented 4 months ago

Hello, I am trying to migrate the following apache httpd rule to spring gateway. So far it appears to be not working. Can you please lend me a helping hand?

ProxyPassMatch ^(\/v1)?\/rest\/v\/([^\/]+)\/m\/([^\/]+)\/path\/from\/(-?\d+\.?\d*),(-?\d+\.?\d*)\/to\/(-?\d+\.?\d*),(-?\d+\.?\d*)(\?.*)?$ http://localhost:8080/api/v1/public/v/$2/m/$3/path/from/$4,$5/to/$6,$7

mailsanchu commented 4 months ago

An example would be /rest/v/101/path/from/-10,10/to/20,-20

mailsanchu commented 4 months ago
    - id: v1_u_me_v_messages
      uri: http://localhost:8082
      predicates:
     `   - Path=/rest/v/{a:\d+}/path/m/{b:\d+}/path/from//{c:\d+},{d:\d+}/to/{e:\d+},{f:\d+}`
mailsanchu commented 4 months ago

Comma seems to have an issue there

spencergibb commented 4 months ago

Is the == a typo?

All I can really do is point you at the path pattern javadoc, which gives the most detailed explaination of the syntax https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/pattern/PathPattern.html

mailsanchu commented 4 months ago

Yes it is a typo. I need to extract fields separated by comma and process it internally. I was hoping somebody had a better solution

mailsanchu commented 4 months ago

Thank you for your response @spencergibb