You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 2, 2022. It is now read-only.
In other words, the `ServerRequest` object gives you the ability to decode the request into a struct of your choice. The `ServerResponse`, conversely, encodes a struct into the the response body and provides the ability to enter a status code.
164
164
165
+
## Content negotiation
166
+
167
+
If you wish to perform content negotiation on the server side, this library now supports switching between text and JSON output. This can be invoked using the `NewServerHandlerNegotiate` method instead of `NewServerHandler`. This handler will attempt to switch based on the `Accept` header sent by the client. You can marshal objects to text by implementing the following interface:
168
+
169
+
```go
170
+
typeTextMarshallableinterface {
171
+
MarshalText() string
172
+
}
173
+
```
174
+
165
175
## Using multiple handlers
166
176
167
177
This is a very simple handler example. You can use utility like [gorilla/mux](https://github.com/gorilla/mux) as an intermediate handler between the simplified handler and the server itself.
0 commit comments