Skip to content




JAR services

API Explorer

Service discovery & registration

When using Martini with a cluster manager, clients of a service can use Martini's service registry API (or the cluster manager) to determine the location of a service instance to which to send requests. This enables you to programmatically ask for a host that's serving a particular API. This is very useful when using Martini as, or in conjunction with microservices.

Gloop APIs in a cluster

By default, Gloop APIs are automatically registered as services1 against the cluster manager in use, and the namespace is used as their lookup names.

The service registry API includes methods that will perform the lookup for you, and rewrite the URL you give it as well, depending on the protocol. This means at runtime, you can query the service registry using an API namespace as the host (complete with URI segments), and it will return a fully-formed URL that points to a server that can serve the reuqest.

For example, if you have a Gloop API registered with the namespace my.api.HelloWorld, you can query the service registry using the URL srhttp://my.api.HelloWorld/foo/bar. With this, the API will return a rewritten URL, such as, which you can then use to execute your desired service. Notice that the URL passed to the API uses srhttp as the scheme - this is how Martini knows to look it up. If the scheme isn't srhttp, Martini won't perform a lookup and rewrite the URL, instead it will return with the URL it received.

HTTP one-liners in Martini

There are two HTTP clients in Martini, a Gloop-pecific one and a one-liner version for use in Groovy. Both already support the use of the service registry. This means you can use these clients with an sthttp:// URL, and it will do the lookup and URL rewrite for you.

Note that if Martini isn't running in a cluster, the service registry will rewrite URLs, and these URLs will be pointing to the already running Martini instance (in other words, Martini will rewrite the URLs to point to itself).

  1. Eureka only registers entire Martini instances.