Skip to content

Overview

Reza Ahmadi edited this page Feb 1, 2025 · 2 revisions

Http.Request.Builder

Http.Request.Builder is a lightweight, easy-to-use library designed to simplify the process of building and sending HTTP requests in your applications. Whether you're working on a small project or a large-scale application, this package provides a clean and intuitive API to handle HTTP requests with ease.

Key Features

  • 🚀 Simple and Intuitive API: Build HTTP requests effortlessly with a fluent, chainable interface.
  • 🔧 Customizable: Easily add headers, query parameters, and body content to your requests.
  • 🛠 Flexible: Supports various HTTP methods (GET, POST, PUT, DELETE, etc.).
  • 🛡 Error Handling: Built-in mechanisms to handle errors and exceptions gracefully.
  • 🌐 Cross-Platform: Works seamlessly across different environments (.net core, C# console, Asp.net, etc.).

Why Use Http.Request.Builder?

  • Save Time: No more boilerplate code for creating HTTP requests.
  • Improve Readability: Write clean, maintainable code with a fluent API.
  • Focus on Logic: Spend less time configuring requests and more time building your application.

Here’s a quick example to show how easy it is to use Http.Request.Builder:

// Prepare request object.
var request = RequestBuilder.Create("YOUR_URL")
    .Build();
    
// Send request and get response.
var response = await request.SendAsync();

//Console.WriteLine($"{response.StatusCode} {response.Content}");

Another configs

var request = RequestBuilder.Create("YOUR_URL")
    .WithBearerToken("JWT_TOKEN")                 // <--- Authentication as bearer token here!
    .WithHeader("Accept", "application/json")     // <--- Your custom headers!
    .WithHeader("CUSTOM_KEY", "CUSTOM_VALUE")     // <--- Your custom headers!
    .WithRetryAttemptsForFailed(options =>
    {
        options.MaxRetries = 5;                   //   <--- Number of retries after failure!
        options.Delay = TimeSpan.FromSeconds(1);  //   <--- Number of retries after failure!
    })
    .Build();

Clone this wiki locally