featurebase/http
Seebs 8b20406f45 experiment: handle errors more gracefully, but don't stream CreateKeys
We were trying to write an error to a ResponseWriter After attempting to
write to it, and this produces messages about superfluous WriteHeaders,
which is correct. This patch changes things so that we report messages
more clearly and verbosely if we hit them before writing, and if we try
to write and fail, we log the message because that's all we can do.

This does change semantics slightly, in that now we're marshalling
separately from trying to write the marshalled data. I think this is
probably a reasonable call because it lets us get diagnostics about a
hypothetical encoding problem, but in practice I don't think there
should be any encoding problems. So my guess is the actual error will
occur in that last line, and be logged to the server console instead
of failing to write over HTTP.

Also note that this changes some of the messages to include the
underlying error they're complaining about.

We also merge the create/find and index/field cases because only a
couple of lines of code changed between four largeish functions,
and we test some of the failure cases.

We don't have test coverage on the "field isn't provided" type things
because the mux won't actually route things there without them, so
far as I know.
2021-12-01 11:06:54 -06:00
..
client.go refactoring experiment 2021-11-05 13:06:38 -05:00
client_test.go Import/ImportValue API rework and improvements 2021-11-05 13:06:38 -05:00
error.go Fix linter issues: vet 2018-07-19 11:37:50 -05:00
handler.go experiment: handle errors more gracefully, but don't stream CreateKeys 2021-12-01 11:06:54 -06:00
handler_internal_test.go Add schema endpoint 2021-08-19 09:50:59 -05:00
handler_test.go experiment: handle errors more gracefully, but don't stream CreateKeys 2021-12-01 11:06:54 -06:00
translator.go FeatureBase Renaming: changing go.mod module name for featurebase 2021-07-19 09:20:30 -07:00
translator_test.go FeatureBase Renaming: changing go.mod module name for featurebase 2021-07-19 09:20:30 -07:00