Coder Social home page Coder Social logo

hugo-pivaral / netneuron Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 12 KB

NetNeuron is a comprehensive Swift networking library designed to simplify the process of making and handling HTTP requests. This framework simplifies interaction with RESTful APIs, managing the complexity of network communication, and helps developers create more efficient, cleaner code.

License: MIT License

Swift 100.00%

netneuron's Introduction

Platform: iOS 16.0+ Language: Swift 5 License: MIT

NetNeuron ๐Ÿง 

NetNeuron is a robust Swift networking library specifically crafted to streamline the process of making and managing HTTP requests. Designed with RESTful APIs in mind, this framework effectively handles the intricacies of network communication, enabling developers to write more efficient and cleaner code. Additionally, NetNeuron seamlessly integrates with SwiftUI projects, making it an ideal solution for modern, Swift-centric app development.

Features

  • Swift Native: NetNeuron is built with 100% Swift libraries, which means no external dependencies are required for it to work. This promotes easier integration and ensures seamless compatibility with Swift projects.
  • User-friendly: The design of NetNeuron enables clear and concise code, making it easier for developers to understand and implement.
  • Flexible: It allows for easy customization of request configuration.
  • Modular: The separation of functionalities into distinct classes and structures encourages reusability and maintainability.
  • Supports Asynchronous Operations: With built-in support for async/await syntax, NetNeuron is ready for modern asynchronous programming.
  • Thorough Error Handling: NetNeuron includes a comprehensive suite of networking errors, providing more information about what went wrong and where.

Classes

  • HTTPMethod: This enum encapsulates all standardized HTTP methods, providing a structured way to specify the request method when configuring API calls.
  • ClientConfiguration: This struct serves as a container for user-defined network configurations. It includes the host URL, default headers, URLSession, and the JSON encoder/decoder settings for a NetNeuronClient.
  • NetNeuronClient: A sophisticated class that orchestrates and executes networking operations using URLSession. It provides a clean interface for making requests to an API and handles response data conversion.
  • NetNeuronError: A comprehensive enumeration of potential networking errors. This enum enhances error-handling capabilities by outlining various issues that could arise during network requests, from API errors to connection issues.
  • NetNeuronResource: This protocol establishes the fundamental properties of a networking resource that enumerates all possible endpoints of an API. Any struct or enum adhering to this protocol must have a corresponding Resource defined, representative of a specific API endpoint.
  • Resource: This struct provides a model for specifying the necessary details of a network resource, including the HTTP method, endpoint, and any relevant query parameters. It provides utility functions for appending routes and parameters, offering a fluent API for modifying and building resource paths.

Requirements

iOS 16.0 and higher

Installation

Installation is only available through Swift Package Manager:

dependencies: [
  .package(url: "https://github.com/hugo-pivaral/NetNeuron.git", .exact("1.0.0")),
],

After installing the SPM into your project import NetNeuron with

import NetNeuron

Usage

Here is a basic example of how to use NetNeuron for a simple GET request:

import NetNeuron

// Set up client configuration
let config = ClientConfiguration(
    hostURL: "https://api.example.com/",
    headers: ["Content-Type": "application/json"]
)

// Create a networking client with the configuration
let client = NetNeuronClient(configuration: config)

// Define a resource
let resource = Resource(.GET, "my/endpoint/example")

// Define a model for the response data you expect to receive
struct ResponseData: Decodable {
    let name: String
    let id: Int
}

// Send the request
Task {
    do {
        let response: ResponseData = try await client.request(
            to: resource,
            expecting: ResponseData.self,
            errorType: NetworkingError.self
        )
        // Do something with the response
        print("Name: \(response.name), ID: \(response.id)")
    } catch {
        // Handle any errors
        print("An error occurred: \(error)")
    }
}

Author

Hugo Pivaral

License

NetNeuron is under the MIT license. See LICENSE for details.

netneuron's People

Contributors

hugo-pivaral avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.