Draft Content API
Introduction
Draft content API is a microservice that provides access to draft content stored in PAC.
The service is a simple proxy to UPP Content API.
Installation
Download the source code, dependencies and test dependencies:
mkdir $GOPATH/src/github.com/Financial-Times/draft-content-api
cd $GOPATH/src/github.com/Financial-Times
git clone https://github.com/Financial-Times/draft-content-api.git
cd public-things-api
go build .
Running locally
-
Run the tests and install the binary:
go test -race ./... -v
go install
-
Run the binary (using the help
flag to see the available optional arguments):
$GOPATH/bin/draft-content-api [--help]
Options:
--app-system-code="draft-content-api" System Code of the application ($APP_SYSTEM_CODE)
--app-name="draft-content-api" Application name ($APP_NAME)
--app-timeout="8s" Endpoints Timeout Duration ($APP_TIMEOUT)
--port="8080" Port to listen on ($APP_PORT)
--content-rw-endpoint="..." Endpoint for draft content RW ($DRAFT_CONTENT_RW_ENDPOINT)
--content-endpoint="..." Endpoint to get content from CAPI ($CONTENT_ENDPOINT)
--content-api-key="..." API key to access CAPI ($CAPI_APIKEY)
--api-yml="..." Location of the API Swagger YML file ($API_YML)
--validator-yml="..." Location of the validator YML file (VALIDATOR_YML)
--origin-IDs="..." Allowed originID header ($ORIGIN_IDS)
-
Test:
-
Either using curl:
curl http://localhost:8080/drafts/content/b7b871f6-8a89-11e4-8e24-00144feabdc0 | json_pp
-
Or using httpie:
http GET http://localhost:8080/drafts/content/b7b871f6-8a89-11e4-8e24-00144feabdc0
Build and deployment
Service endpoints
Note that the read endpoint is /drafts/content/{uuid}
whereas the write endpoint is /drafts/nativecontent/{uuid}
.
GET
Using curl:
curl http://localhost:8080/drafts/content/b7b871f6-8a89-11e4-8e24-00144feabdc0 | json_pp`
Or using httpie:
http GET http://localhost:8080/drafts/content/b7b871f6-8a89-11e4-8e24-00144feabdc0
At the moment this endpoint is a proxy to the content available in UPP,
so it returns a payload consistent to the Content API in UPP.
PUT
Using curl:
curl -X PUT http://localhost:8080/drafts/nativecontent/b7b871f6-8a89-11e4-8e24-00144feabdc0 --data-binary "@/path/to/file.json"
This returns a 200 status with no body.
Healthchecks
Admin endpoints are:
/__gtg
/__health
/__build-info
The /__health
and /__gtg
check the availability of:
- the generic R/W service (where draft content is stored in native format)
- the draft content validator service (where draft content is validated for UPP format)
- the UPP Content API (where published content is stored)
Logging
- The application uses go-logger; the log file is initialised in main.go.
- Logging requires an
env
app parameter, for all environments other than local
logs are written to file.
- When running locally, logs are written to console. If you want to log locally to file, you need to pass in an env parameter that is !=
local
.
- NOTE:
/__build-info
and /__gtg
endpoints are not logged as they are called every second from varnish/vulcand and this information is not needed in logs/splunk.
Change/Rotate sealed secrets
Please refer to documentation in pac-global-sealed-secrets-eks. Here are explained details how to create new, change existing sealed secrets.