databricks-cli/acceptance/bundle/debug
Denis Bilenko 4034766c93
acc: Simplify writing handlers; support headers in responses (#2338)
## Changes

Handlers now receive testserver.Request and return any which could be
- string or []byte (returns it as is but sets content-type to json or
plain text depending on content)
- struct (encodes it as json and sets content-type to json)
- testserver.Response (full control over status and headers)

Note if testserver.Response is returned from the handler, it's Body
attribute can still be an object. In that case, it'll be serialized and
appropriate content-type header will be added.

The config is now using the same testserver.Response struct, the same
logic applies both configured responses and responses returned from
handlers.

As a result, one can set headers both in Golang handlers and in
test.toml.

This also fixes a bug with RecordRequest not seeing the body if it was
already consumed by the handler.

## Tests
- Existing rests. 
- acceptance/selftest/server is extended to set response header.
2025-02-12 13:00:57 +00:00
..
databricks.yml Always print warnings and errors; clean up format (#2213) 2025-02-07 11:29:40 +00:00
out.stderr.parallel.txt acc: Simplify writing handlers; support headers in responses (#2338) 2025-02-12 13:00:57 +00:00
out.stderr.txt acc: Simplify writing handlers; support headers in responses (#2338) 2025-02-12 13:00:57 +00:00
output.txt Always print warnings and errors; clean up format (#2213) 2025-02-07 11:29:40 +00:00
script Fix flaky acceptance test (#2310) 2025-02-07 16:17:50 +00:00
test.toml Always print warnings and errors; clean up format (#2213) 2025-02-07 11:29:40 +00:00