Swiftpack.co - viralplatipuss/HTTPIO as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by viralplatipuss.
viralplatipuss/HTTPIO 0.0.6
HTTP IO type and handler for use with the SimpleFunctional library
⭐️ 0
🕓 3 years ago
.package(url: "https://github.com/viralplatipuss/HTTPIO.git", from: "0.0.6")

HTTPIO

HTTP IO type and handler for use with the SimpleFunctional library.

Provides a very basic IO handler for handling HTTP requests. Will be extended as needed to handle more complex requests.

This is powered using Vapor's HTTP library, which means it is a multi-platform IO handler. Linux, Mac, iOS

public struct HTTPIO: IO {
    
    public enum Input {
        public enum RequestResult {
            case failed(errorMessage: String)
            case responded(httpStatusCode: UInt, bodyBytes: [UInt8])
        }
        
        case requestStarted(id: UInt, hostname: String, path: String)
        case requestEnded(id: UInt, result: RequestResult)
    }
    
    public enum Output {
        /// Make an HTTP request to download bytes.
        /// This will always produce a requestStarted input. The id of which can be used to identify the response later.
        case requestBytes(hostname: String, path: String)
        
        /// Attempts to forcefully end an existing HTTP connection, if it exists for the given id.
        /// If the connection was able to be force ended, this will be a failure input result.
        case forceEndRequest(id: UInt)
    }
}

GitHub

link
Stars: 0
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics