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

add yaml support #165

Merged
merged 1 commit into from
Jun 4, 2018
Merged

add yaml support #165

merged 1 commit into from
Jun 4, 2018

Conversation

StrongMonkey
Copy link

No description provided.

@StrongMonkey StrongMonkey changed the title Yaml2 add yaml support May 22, 2018
types/encoder.go Outdated
return json.NewEncoder(writer).Encode(v)
}

func YamlEncoder(writer io.Writer, v interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to YAML, not Yaml

parse/parse.go Outdated
return "json"
}

func isYaml(req *http.Request) bool {
return req.Header.Get("Accept") == "application/yaml"
Copy link
Contributor

Choose a reason for hiding this comment

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

A client can send multiple Accept headers to say different content types they accept. So you need to see if it's in one of the headers

AddCommonResponseHeader(apiContext)
apiContext.Response.Header().Set("content-type", "application/json")
if j.Type == "json" {
Copy link
Contributor

Choose a reason for hiding this comment

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

can the type just have j.ContentType and just set content-type = j.ContentType

@@ -13,26 +12,32 @@ import (
"github.com/sirupsen/logrus"
)

type JSONResponseWriter struct {
type JSONOrYAMLResponseWriter struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

This really has nothing to do with JSONorYaml now. Can you rename to EncodingResponseWriter

@ibuildthecloud ibuildthecloud merged commit 59c4a29 into rancher:master Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants