Content API layer for GOV.UK. Being deprecated.
Ruby Shell
Latest commit 97a703a Mar 28, 2017 @suzannehamilton suzannehamilton committed on GitHub Merge pull request #281 from alphagov/update-adapters
Update gds-api-adapters gem to get the latest special route publishing
Permalink
Failed to load latest commit information.
config Fix oauth environment credentials for GDS::SSO Nov 24, 2016
lib Remove licence related methods Feb 28, 2017
test Remove licence related methods Feb 28, 2017
.gitignore Configure Rack::Cache from a YAML file. Apr 11, 2013
.ruby-version Update Ruby dependency to 2.3.0 Aug 19, 2016
.travis.yml Bump ruby patch version for security fixes Nov 25, 2013
CONTRIBUTING.md Define contributing guide Nov 29, 2013
Gemfile Update gds-api-adapters gem to get the latest special route publishing Mar 28, 2017
Gemfile.lock Update gds-api-adapters gem to get the latest special route publishing Mar 28, 2017
Jenkinsfile Restrict builds to mongo-2.4 Jan 6, 2017
README.md Fix "placed" typo Aug 12, 2013
Rakefile Merge pull request #5 from alphagov/router-registration Sep 3, 2012
config.rb Merge pull request #184 from alphagov/remove_exception_mailer Jun 4, 2014
config.ru Use env vars for rack cache config Nov 16, 2016
console Add a `console` script for interactive hackery. Jan 14, 2013
env.rb Set Time.zone to avoid Ruby error when running app Mar 18, 2013
govuk_content_api.rb Remove licence related methods Feb 28, 2017
jenkins.sh Add govuk-lint Apr 5, 2016
jenkins_branches.sh Add Jenkins branch build script Mar 4, 2014
mongoid.yml Update mongoid and secret key configurations. Apr 5, 2016
rack-cache.heap.yml Configure Rack::Cache from a YAML file. Apr 11, 2013
rack-cache.memcached.yml Add example memcached configuration for Rack::Cache Dec 10, 2013
startup.sh Remove reference to Rabl Jan 19, 2015

README.md

GOV.UK Content API

The content API provides a read-only API layer to access information about any content on GOV.UK; it is how front-end applications (such as frontend and Smart Answers) access content, metadata and search.

Testing

Run the following to ensure your environment is set up correctly:

bundle install && bundle exec rake

Caching

To enable caching in development, you'll need to pick a caching backend by symlinking one of the Rack::Cache config files. For instance, to set up a memory-backed cache:

ln -s rack-cache.heap.yml rack-cache.yml

Then, to run the server:

API_CACHE=1 bundle exec rackup -p 3022

If you have access to the development repository, run

API_CACHE=1 bowl contentapi

or

API_CACHE=1 foreman start contentapi

Asset Manager

If your models include media assets such as images and video, you will need to run the asset-manager app alongside the content api.

See the asset-manager project for app-specific setup instructions.

Content API needs an OAuth bearer token in order to authenticate with Asset Manager. By default, this is loaded from the CONTENTAPI_ASSET_MANAGER_BEARER_TOKEN environment variable in config/initializers/gds_api.rb.

To obtain this bearer token, you will first need to generate OAuth keys for the content API application. In the signonotron2 directory, run:

rake applications:create name=contentapi description="content api" home_uri="http://contentapi.dev" redirect_uri="http://contentapi.dev/auth/gds/callback"

The provided OAuth tokens should be placed into the CONTENTAPI_OAUTH_ID and CONTENTAPI_OAUTH_SECRET environment variables

You can then create an API user in the signonotron2 application.

rake api_clients:create[contentapi,contentapi@example.com,asset-manager,signin]

This will generate the bearer token you need.