URL alias endpoint
The URL alias endpoint binds short, easy to remember URL paths to the methods inside your services, scripts and code.
This makes your APIs look much nicer to your customers, and allows for URLs to invoke different code over time
without changing the URL itself. This endpoint has no requirements in terms of method signatures
for code being invoked. All services that are invoked through this endpoint are available in the
Martini root context /api
.
Properties
Property | Default | Description |
---|---|---|
Name | (required) | The name of the endpoint. |
Service | (required) | The service to execute when the endpoint is triggered. |
Run As | Anonymous |
The user to run the service in behalf of. This is logged to Tracker. |
Document Type | <Name of endpoint type> | The document type to be used when adding documents to Tracker as this endpoint is triggered. |
Auto Start | true |
Whether or not to automatically start the endpoint upon package startup. |
URL alias-specific configuration
Properties | Default | Description |
---|---|---|
URL Alias | (required) | The URL pattern to be used by the service. |
Request Method | The HTTP method used to match the request. | |
Secured | false |
If true , only authorized users can hit the URL. |
Users | The users allowed to execute the URL alias. | |
Groups | The groups allowed to execute the URL alias. |
Example
Gloop as service
Consider the following example:
This endpoint exposes the configured service under the URL GET /api/sendJMSMessage
, with request parameters
jmsQueue
and messageContent
. These request parameters correspond to the input of the service:
Sending the request GET /api/sendJMSMessage?jmsQueue=queue://news&messageContent=Hello
invokes the underlying service.
Want more examples?
The distribution ships with a Martini package called examples
, which
contains services (including the above example) demonstrating more use cases.
Groovy as service
We can replicate the above example in Groovy. Consider the following snippet:
1 2 3 4 5 6 7 8 |
|
Configuring this as a service of the endpoint above will expose it as well under the same URL:
GET /api/sendJMSMessage?jmsQueue=queue://news&messageContent=Hello
.
publishTo
what?
The method publishTo
used in this snippet is a Groovy extension to the String
class.
This allows developers to conveniently publish, in this case, a String
to a JMS destination, in one line.