Skip to content

implements automatic Content Negotiation#28

Merged
xentek merged 1 commit intomasterfrom
content-negotiation
Mar 11, 2017
Merged

implements automatic Content Negotiation#28
xentek merged 1 commit intomasterfrom
content-negotiation

Conversation

@xentek
Copy link
Copy Markdown
Member

@xentek xentek commented Mar 11, 2017

  • adds Respond() helper function to be used in Endpoint method handlers
  • Respond() takes an http.ResponseWriter, http.Request, and user supplied: status, body, and 0 or more http.Headers
  • if value of Accept header ends in json, body will be encoded as json
  • if value of Accept header ends in xml, body will be encoded as xml
  • switches Present(), Representation and friends to just using struct tags to aid in encoding RootResource in xml/json
  • adds EndpointResource to replace the old Representation

fixes #17

- adds `Respond()` helper function to be used in Endpoint method handlers
- `Respond()` takes an http.ResponseWriter, http.Request, and user supplied: status, body, and 0 or more `http.Header`s
- if value of `Accept` header ends in `json`, `body` will be encoded as json
- if value of `Accept` header ends in `xml`, `body` will be encoded as xml
- switches `Present()`, `Representation` and friends to just using struct tags to aid in encoding `RootResource` in xml/json
- adds `EndpointResource` to replace the old `Representation`

fixes #17
@xentek xentek added this to the v0.0.4 milestone Mar 11, 2017
@xentek xentek merged commit 905d441 into master Mar 11, 2017
@xentek xentek deleted the content-negotiation branch March 11, 2017 23:03
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.

Content Negotiation

1 participant