Tagging and Filtering

Contracts are auto tagged with the name of every directory they are in relative to the directory the contracts are loaded from. For example, contracts loaded from webclient/v0.0.1/login/ will be tagged with ‘webclient’, ‘v0.0.1’ and ‘login’.

Tags can also be added manually to the contract file, a sample is shown below :

{
  "tags" : ["admin", "core"],
  "request" : {
    "method" : "POST",
    "path" : "/kv/pair",
    "headers": {
      "Content-Type" : "application/json"
    },
    "body": "{
      "key": "age",
      "value": 27
    }
  },
  "response" : {
    "status" : 201,
    "body" : {
      "key": "age",
      "value": 27
    }
  }
}

This contract will also be tagged with ‘admin’ and ‘core.

Filtering

The ContractClient and ContractServer can either retain or exclude certain contracts based on their tags, the syntax is identical for both. For example to execute the Contracts tagged with ‘core’

Multiple tags can also be passed as arguments

And contracts with any of these tags will be executed. The Opposite is also possible.

This will exclude every contract with the tag ‘core’. Retain and exclude can be used in conjunction with one another. However, their ordering will need to be taken into account by the user.