Skip to content

Operations

New operation

Open the + button at the bottom of the Operations tab and choose the HTTP method of the operation. The methods are New Get, New Post, New Put and New Delete.

The menu of the HTTP methods

On the left you select any operation you created. On the right, the operation has five tabs: Configuration, Parameters, Implementation, Caching & Logging and Security. A new operation is named ExposedOperation, and the Operation Endpoint at the bottom shows its method and path, for example GET: /ExposedOperation. The examples below describe a service that returns product information.

Configuration

The basic properties of the endpoint:

Property Description
Name The name of the operation.
Verb The HTTP method. Its initial value is the one you chose when you created it.
Path The endpoint of the operation. It starts as the name, and the Operation Endpoint at the bottom shows it.
Notes Notes that help the developer remember and maintain the service.
Request Sample Notes Developer notes about the request parameters.
Response Sample Notes Developer notes about the response.

The Configuration tab of an operation

Parameters

The Parameters tab lists the parameters of the operation. A new operation says This operation has no parameters.

The Parameters tab of an operation

Implementation

The Implementation tab holds the code editor, where you write the logic of the service in Mamba. A new operation starts as function void ExposedOperation(). Change the return type and the parameters in the signature as you need. The return type decides which classes appear in the Data Contracts. The parameters are passed in the URL of the endpoint, as a query string, or in the body of a form post, depending on the verb.

The Implementation tab of an operation

A sample implementation that returns product information for an id:

Example

function Domain.Product ProductInfo(int productId)
{
    var product = Domain.Product.GetByKey(productId, false);
    return product;
}

Caching & Logging

The tab has two groups, Logging and Caching.

The Caching & Logging tab of an operation

Logging. Enable Access Log has the same effect as for the actions of a form controller. See Access Log.

Caching. Enable Cache caches the outcome of a request and serves it again for identical requests. The default configuration comes from the caching settings of the application. Cache Per User keeps a separate cache for each user. Override Default Cache Settings lets the service use its own policy, with the same settings as the application's, and one more, the Timespan. Apart from setting the timespan by hand, you can define an Expiration Method, which returns a timespan from the values of the request parameters and of the response:

Example

function TimeSpan Expiration(int productId, Domain.Product response)
{
    return CommonLib.Utilities.CreateTimeSpan(0, 1, 0);
}

Security

The Security tab decides who may call the operation. It offers All Anonymous Users and Allow all Authenticated, and both are checked for a new operation. See Security for the rest.

The Security tab of an operation