Features of the Fiber Client
mainThe Fiber Client is an easy-to-use HTTP client based on fasthttp, inspired by Resty and Axios. Key capabilities include:
- HTTP Methods: Supports
GET,POST,PUT,DELETE,HEAD,PATCH,OPTIONS, etc. - Fluent API: Provides simple and chainable methods for configuring requests and settings.
- Flexible Request Bodies: Accepts
string,[]byte,map, orslice. It automatically detectsContent-Typeand supports buffer processing for files. - Low-level Access: You can access the native
*fasthttp.Requestinstance during middleware and request execution viaRequest.RawRequest. The request body can be read multiple times usingRequest.RawRequest.GetBody(). - Rich Responses: Access response data as
[]byteusingresponse.Body()or as astringusingresponse.String(). - Automatic Marshalling:
- Automatically marshals/unmarshals JSON and XML content types.
- Defaults to JSON if a struct/map is provided without a
Content-Typeheader. - Supports automatic unmarshalling for success scenarios via
Request.SetResult()/Response.Result()and error scenarios viaRequest.SetError()/Response.Error(). - Supports RFC7807 (
application/problem+json&application/problem+xml). - Allows overriding JSON and XML Marshaller/Unmarshaller via options.