Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧰 What's being changed?
This sends a valid hardcoded payload (in the form of the
data.json
file)to the Readme API with all the proper headers and authentication.
The middleware now takes an API key during initialization and no longer
needs an endpoint which has become a constant.
The hard-coded data we wrote is valid according to HAR
1.2. We noticed that
there are some required fields from the spec that are neither mentioned
by the API nor used in the nodejs implementation. We decided to include
them for validity sake and at some point the backend might want to fully
support the HAR 1.2 spec.
The added fields are:
entries.cache
entries.timing
entries[].request.cookies
entries[].request.headerSize
entries[].request.bodySize
entries[].response.cookies
entries[].response.headerSize
entries[].response.bodySize
entries[].response.redirectURL
entries[].response.httpVersion
Some of these are empty arrays or objects but the keys are required to
be present.
As part of our development process, we introduced json-schema to check
the generated JSON we use (for now the static JSON file). We wrote a
schema file for the Readme.io-specific structure but were able to re-use
an existing implementation for the HAR
format.
🧪 Testing
There is an automated test the uses json-schema to guarantee the JSON is in the right format. We also manually tested this with the following Rack app:
run it on the command-line with:
Make a request:
then log into Readme.io dashboard and expect to see your request(s) there. Note that all the data will be from the hard-coded JSON file rather than actual data from the request.