Skip to content

Operations

New Operation

To add a new Operation go to the Add New Operation button and select the type your RESTful exposed service. The following HTTP methods are available:

Add New Operation

In the left part of this workspace you can select any operation you created, and configure it by setting several properties and implementing the code it executes.

Add New Operation

The service configuration and implementatio is segmented in 4 categories and each one has its own tab: Configuration, Implementation, Caching & Logging and Security. Each tab is explained in detail below using a service example that implements a REST API for requesting product information.

Configuration

Here you can set the most basic properties for your REST API. The following options are available:

Property Description
Name This is the name of your current operation
Verb The type of the HTTP request that this operation is accepting. Its initial value is set to the type you choose upon creation
Path The endpoint of the service. It can be seen at the bottom of the current tab
Notes Notes that can help the developer remembering and maintaining the service
Request Sample Notes Developer notes for the API's request parameters
Response Sample Notes Developer notes regarding the API's response

In the previous screenshot these fields are filled according to our example service, that accepts a product id and returns its detailed info.

Implementation

The implemtation tab contains the Code Editor, to write the logic of the service in Mamba. You can add parameters and edit the function return type in the signature according to your needs. The return type affects the Data Contracts section. which will be covered later on. The parameters can be passed on the endpoit URL of the API, either as a querystring or through a form post, depending on the Verb type you chose in the configuration section.

Sample implementation for requesting product info for a specific id:

Example

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

Cashing & Logging

Logging

Enabling or disabling Access Log has the same effect with the Form Controller Actions. For detailed reference see Access Log.

Cashing

Enabling Caching as the name suggests caches the outcome of a request and serves it again on identical ones it may receive later on. The default caching configuration is inherited from the application's configuration caching configuration. For detailed reference see Caching.

Enabling Cache Per User creates a separate cache for each different user that accesses the service.

If you want to enforce different caching policies per service, that differ from the default one the application uses you can enable the Override mode. The settings here are the same as those in the default application caching configuration. This tab offers one additional option regarding the Timespan of the cache. Apart from the Default option where you can set the Timespan values by hand, there is a custom option in which you can define an Expiration Method. This method returns a timespan while it has available the requested parameter values and the API's response value:

Example

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

This option gives you the ability to dynamicaly modify the Timespan, through accessing the requested objects and appling a different caching logic.

Security

The Security tab allows you to manage which users are allowed to access your service. Security configuration is pretty straightforward and common among other compononents of your application. For more details refer to the Security Section configuration.