Hey everyone!
I'm excited to introduce my latest creation, SwiftRequest, a powerful and lightweight HTTP client library for Swift. With SwiftRequest, you can streamline the construction and execution of HTTP requests while eliminating the repetitive boilerplate code. It's designed to be type-safe and easy to use.
With SwiftRequest, defining a service to fetch quotes is a breeze. Take a look at this example:
@Service(resource: "quotes")
protocol QuoteService {
@GET("random")
func getRandomQuotes(@QueryParam limit: Int?) async throws -> [Quote]
@GET("{id}")
func getQuote(@Path by id: String) async throws -> Quote
}
Making a request using SwiftRequest is as simple as creating an instance of the service and calling the desired method:
let service = QuoteServiceImpl(baseURL: "https://api.quotable.io")
let quotes = try await service.getRandomQuotes(limit: 5)
let quote = try await service.getQuote(by: "69Ldsxcdm-")
I hope you find SwiftRequest valuable for your HTTP client needs in Swift. Give it a try and let me know your feedback and suggestions. Happy coding!