Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loki: Querier APIs respond JSON Content-Type #2665

Merged
merged 1 commit into from
Sep 29, 2020
Merged

Loki: Querier APIs respond JSON Content-Type #2665

merged 1 commit into from
Sep 29, 2020

Conversation

cnbailian
Copy link
Contributor

What this PR does / why we need it:

Add json response so that http client tool can display data better.

@CLAassistant
Copy link

CLAassistant commented Sep 24, 2020

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2020

Codecov Report

Merging #2665 into master will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2665      +/-   ##
==========================================
- Coverage   61.46%   61.44%   -0.02%     
==========================================
  Files         173      173              
  Lines       13421    13428       +7     
==========================================
+ Hits         8249     8251       +2     
- Misses       4422     4428       +6     
+ Partials      750      749       -1     
Impacted Files Coverage Δ
pkg/loki/modules.go 3.70% <0.00%> (-0.03%) ⬇️
pkg/util/server/middleware.go 58.33% <0.00%> (-41.67%) ⬇️
pkg/logql/evaluator.go 92.81% <0.00%> (+0.42%) ⬆️

@cyriltovena
Copy link
Contributor

Nice should the query-frontend have the same middleware ? Can you also sign the CLA.

Again thank you !

@cnbailian
Copy link
Contributor Author

Nice should the query-frontend have the same middleware ? Can you also sign the CLA.

Again thank you !

I think there should be. Has been signed.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for this change !

func ResponseJSONMiddleware() middleware.Interface {
return middleware.Func(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Add("Content-Type", "application/json; charset=UTF-8")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if Set would be better here ? So that whatever it was it is replaced. Pretty sure it's no a big deal here, I'll merge it as is tomorrow if you don't have time to make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. This should be a replacement, not an Add. I'll fix it right now.

@cyriltovena cyriltovena merged commit 0ac1ce4 into grafana:master Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants