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
Gísli Konráð Björnsson edited this page Jan 16, 2019
·
4 revisions
Extensions
SolidHttp is created with extensions and you can create your own quite easily.
Extension examples
Here are some examples on how to extend SolidHttpRequest. The first adds a function that adds a header with key "x-standard-header" and fixed text value "standard". The second example adds a function that adds a authorization header with a bearer token.
publicstaticclassStandardHeaderExtensions{publicstaticISolidHttpRequestWithProprietaryHeader(thisISolidHttpRequestrequest){returnrequest.WithHeader("x-proprietary-header","I am proprietary");}publicstaticISolidHttpRequestWithBearerToken(thisISolidHttpRequestrequest,stringtoken){returnrequest.WithHeader("Authorization",$"Bearer {token}");}}
ISolidHttpRequest is not the only useful thing to extend. Solid.Http.Core has multiple extensions classes where you can get some ideas on how to to create your own by looking them over.