ROA Auto discovery

REST relies on hypermedia and links in order to decouple clients from physical location of resources. In Fantastico, we allow clients to introspect the platform in order to know which are the registered resources. Following some simple steps you can enable autodiscovery of resources.

Integration

  1. Activate ROA Discovery extension.

    fsdk activate-extension --name roa_discovery --comp-root <comp_root>
    
  2. Start your project

  3. Access http://localhost/roa/resources

By default, ROA Discovery extension defines a sample resource (Sample Resource) which must be always present in your discovery registry.

Current limitations

  • ROA discovery supports only application/json content type for responses.

Technical summary

class fantastico.contrib.roa_discovery.discovery_controller.RoaDiscoveryController(settings_facade, registry_cls=None)[source]

This class provides the routes for introspecting Fantastico registered resources through ROA. It is extremely useful to surf using your browser and to not be required to hardcode links in your code. Typically, you will want to code your client side applications against resources name and you are going to use this controller to find the location of those records.

By default, all ROA resources are mapped on /api/ relative to current project root. You can easily change this behavior by modifying the settings of your application (fantastico.settings.BasicSettings - property roa_api_url)

handle_list_resources_options(*args, **kwargs)[source]

This method handles all OPTIONS cors requests coming for resources registry listing.

list_registered_resources(*args, **kwargs)[source]

This method list all registered resources as well as a link to their entry point.

// ROA api is mapped on a subdomain: roa.fantasticoproject.com
// listing is done by GET http://fantasticoproject.com/roa/resources HTTP/1.1

{
    "Person": {1.0 : "http://roa.fantasticoproject.com/1.0/persons",
               "latest": "http://roa.fantasticoproject.com/latest/persons"},
    "Address": {1.0 : "http://roa.fantasticoproject.com/1.0/addresses",
                2.0 : "http://roa.fantasticoproject.com/2.0/addresses",
                "latest": "http://roa.fantasticoproject.com/latest/addresses"}
}
// ROA api is mapped on a relative path of the project: http://fantasticoproject.com/api/
// listing is done by GET http://fantasticoproject.com/roa/resources HTTP/1.1

{
    "Person": {1.0 : "http://fantasticoproject.com/api/1.0/persons",
               "latest": "http://roa.fantasticoproject.com/api/latest/persons"},
    "Address": {1.0 : "http://roa.fantasticoproject.com/api/1.0/addresses",
                2.0 : "http://roa.fantasticoproject.com/api/2.0/addresses",
                "latest": "http://roa.fantasticoproject.com/api/latest/addresses"}
}