...
A topology file sketch containing a use of the "default" service.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<topology> ... <service> <role>...</role> <name>generic</name> <url>...</url> <param> <name>pattern</name> <value>custom/v1/**?**</value> </param> <param> <name>rewrite</name> <value>custom-rewrite-rules.xml</value> </param> </service> </topology> |
Note: Something isn't quite right with the above. Basically I'd prefer if there were a way to specify a chain per pattern but this doesn't support that.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
public class DefaultServiceDeploymentContributor { String getRole() { return "*"; // The "*" will require special handling in the framework. String getName() { return "generic"; } void initializeContribution( DeploymentContext context ) { // NoOp } void contributeService( DeploymentContext context, Service service ) throws Exception { ResourceDescriptor resource = context.getGatewayDescriptor().addResource(); resource.role( service.getRole() ); resource.pattern( service.getParam( "pattern" ); UrlRewriteRulesDescriptor serviceRules = loadRules( service.getParam( "rewrite" ) ); UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" ); clusterRules.addRules( serviceRules ); } // Called after all contributors and before provider finalizeContribution methods. void finalizeContribution( DeploymentContext context ) { // NoOp } } |