You are building an Optic Middleware, that logs traffic in the ECS format (social proof) to the Optic CLI that is running during local development or in your Continuous Integration environment
With the middleware installed, all your test traffic can be observed by Optic even if doesn't go over the network, and you don't need to use api run <x>
commands anymore, your normal commands will work just fine
Building a basic Optic Middleware for your framework
- Log the contents of every request / response to the console. This should take < 30 mins
- Transform that requests / response into ECS using one of the pre-built converts from Elastic < 20 mins.
- Send the traffic to Optic's local CLI
- Then when traffic is observed, it gets uploaded to local Optic daemon and saved in your local capture folder
Making it user friendly:
- Allow users to turn it on/off with config Optics see section 2.1
- Check if the
api
cli is installed before activating the middleware see section 4
tl;dr a logging middleware, built on the open source standard for logging traffic, that logs to Optic so it's easier for Optic to see your test traffic and learn about your API behavior.
Repo Setup
In your repo we expect to see:
- An example project that proxies to HTTPBin
- rewrite the host, forward to httpbin.org??, respond with that respond
- This makes it really easy to test the integration since HTTPBin has known/standard behaviors that are always consistent
- Then build the optic middleware alongside it so we have a reference usage we can test with.
Acceptance Criteria
- The repo structure should be a monorepo for the language in question split by the core language SDK and the separate frameworks that the middleware is built for
- SDK (core)
- frameworks
— framework 1
— framework 2
— framework *
- The core sdk and each framework should be published to the given package manager separately
- The entire repo should be under the MIT license
- The SDK should expose an interface that can receive a configuration object
- The configuration object should contain the following
enabled
a boolean
to tell the library to capture and send HTTP traffic
uploadUrl
a string
to allow pointing the captures to a custom URL, this should default to usingOPTIC_LOGGING_URL
from an environment variable
console
a boolean
to manage if the HTTP request is logged to stdout
for debugging purposes
framework
a string
additional language/framework information to inform Optic of where it is capturing information