cosmo icon indicating copy to clipboard operation
cosmo copied to clipboard

feat(router): expose core.operationContext{variables,rawContent}

Open robmyersrobmyers opened this issue 7 months ago • 0 comments
trafficstars

Motivation and Context

This enables custom modules to obtain operation variables and rawContent through an OperationContext.

The OperationContext interface currently exposes normalized content, but this form does not include any variables that may be added as part of the normalization process.

I am experimenting with a custom module that uses Open Policy Agent for authorization, but in order to pass all the necessary information to OPA I'd have to pull it out of the request context, which seems like extra effort since the data is already present in the operation context. Additionally, I'd like to leverage the normalized operations instead of the raw operations where possible.

Notes

  • I created this PR as support to illustrate what I think would work to solve #1781 but I have not received any feedback from developers on it.
  • I don't see any existing tests directly for OperationContext, so I'm not sure where tests would fit for this fairly trivial change.
  • I think the only documentation that needs to be updated would be auto-generated for pkg.go.dev.

Checklist

  • [ ] I have discussed my proposed changes in an issue and have received approval to proceed.
  • [x] I have followed the coding standards of the project.
  • [ ] Tests or benchmarks have been added or updated.
  • [ ] Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • [x] I have read the Contributors Guide.

robmyersrobmyers avatar Apr 12 '25 13:04 robmyersrobmyers