• Document Up to Date
  • Updated On 4.0.3

Get the Names of Sites Running in Crafter Engine

In this example we create a simple RESTful service that returns the list of sites running in Crafter Engine. You can find the API for the Context Manager HERE


  • None

Step 1: Create a REST Controller

  • Under Scripts/rest right click and click create controller
    • Enter get-sites.get as the controller name
  • Add the following code to the controller.
 1def siteContextManager = applicationContext["crafter.siteContextManager"]
 2def siteContextList = siteContextManager.listContexts()
 3def siteNames = []
 5siteContextList.each { siteContext ->
 6    def name = siteContext.getSiteName()
 7    siteNames.add(name)
10return siteNames

Step 2: Execute the Service