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
Copy file name to clipboardExpand all lines: README.md
+14-5Lines changed: 14 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ And you can do everything asynchronously:
50
50
.AsAsync<Idea>();
51
51
```
52
52
53
-
And you can access the [underlying HTTP message handler][HttpClientHandler], or inject your own to do pretty much whatever you want. The default handler lets you configure a range of features like authentication, cookies, and proxying:
53
+
And you can configure a range of features like credentials and cookies using the default [HTTP message handler][HttpClientHandler]:
@@ -59,23 +59,32 @@ And you can access the [underlying HTTP message handler][HttpClientHandler], or
59
59
60
60
The code documentation provides more details on usage: see [IClient][], [IRequestBuilder][], and [IResponse][].
61
61
62
-
## Configurable formatting
63
-
The client uses .NET's [MediaTypeFormatter][]s for serializing and deserializing HTTP messages. This is the same type used by the underlying HttpClient and the .NET Web API, and the client uses Microsoft's default formatters out of the box. When creating a client for an ASP.NET Web API, this lets you seamlessly use the same formatters on both sides.
62
+
## Extension
63
+
### Custom formats
64
+
The client uses .NET's [MediaTypeFormatter][]s for serializing and deserializing HTTP messages — the same ones used by the HttpClient itself and the ASP.NET Web API. The client uses Microsoft's default formatters by default. When creating a client for an ASP.NET Web API, this lets you seamlessly use the same formatters on both sides.
64
65
65
-
You can use any of the many implementations already available, create your own ([MediaTypeFormatterBase][] might help), or use one of the formatters below. For example, to replace the default JSON formatter with the formatter below:
66
+
You can use any of the many implementations already available (including the Json.NET formatters below), or create your own ([MediaTypeFormatterBase][] might help). For example, to replace the default JSON formatter with the formatter below:
The [Pathoschild.Http.Formatters.JsonNet][] package provides three formats using [Json.NET][]: [BSON][] (`application/bson`), [JSON][] (`application/json`, `text/json`), and [JSONP][] (`application/javascript`, `application/ecmascript`, `text/javascript`, `text/ecmascript`). JSONP requests can include an optional `callback` query parameter that specifies the JavaScript method name to invoke.
74
75
```c#
75
76
client.Formatters.Add(newJsonNetBsonFormatter());
76
77
client.Formatters.Add(newJsonNetFormatter());
77
78
```
78
79
80
+
### Custom message handler
81
+
You can inject your own [HTTP message handler][HttpClientHandler] to do pretty much anything you want. For example, you could easily create a custom handler for unit tests which talks directly to a mock without actual HTTP calls:
0 commit comments