Repository navigation
Conversation
Signed-off-by: Kalle <23356117+kalleep@users.noreply.github.com>
Signed-off-by: Kalle <23356117+kalleep@users.noreply.github.com>
Signed-off-by: Kalle <23356117+kalleep@users.noreply.github.com>
Signed-off-by: Kalle <23356117+kalleep@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
http::ScrapeHandler, so a scrape endpoint doesn't have to wire up negotiation, encoding and the response headers itself.By default it offers every format that is supported and enabled with feature flags. with_formats changes the offered formats, and more options like compression or escaping can be added to the builder later without breaking anything.
handle takes a closure that looks up a request header by its lowercase name, so it works with any HTTP framework without adding dependencies. It returns a ScrapeResponse with the status, the Content-Type and Vary: Accept headers, and the encoded body. If encoding fails, it returns a ScrapeError with the status to respond with and the EncodeError as its source.
Fixes: #385
I updated the api a bit to return
Result<ScrapeResponse, ScrapeError>so that caller can actually inspect the error.