Skip to content

Instantly share code, notes, and snippets.

@helpermethod
Last active August 22, 2017 11:53
Show Gist options
  • Select an option

  • Save helpermethod/7a9c67663391c8a9132a09c38122f18f to your computer and use it in GitHub Desktop.

Select an option

Save helpermethod/7a9c67663391c8a9132a09c38122f18f to your computer and use it in GitHub Desktop.
proxies.groovy
@Grapes([
    @Grab('org.membrane-soa:service-proxy-core:4.4.2'),
    @Grab('ch.qos.logback:logback-classic:1.2.3')
])
import com.predic8.membrane.core.HttpRouter
import com.predic8.membrane.core.config.Path
import com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor
import com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping
import com.predic8.membrane.core.rules.AbstractServiceProxy.Target
import com.predic8.membrane.core.rules.ServiceProxy

new HttpRouter(
    hotDeploy: false,
    rules: [
        new ServiceProxy(
            port: 2000,
            path: new Path(value: '/(rest)?names.*', regExp: true),
            interceptors: [
                new RewriteInterceptor(
                    mappings: [
                        new Mapping(from: '^/names/(.*)', to: '/restnames/name\\.groovy\\?name=$1')
                    ]
                )
            ],
            target: new Target(host: 'thomas-bayer.com', port: 80)
        )
    ]
).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment