GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - XcodesOrg/AsyncHTTPNetworkService: A Network layer for Swift using Concurrency

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

50 Commits
50 Commits

Folders and files

NameName
Last commit message
Last commit date
.swiftpm/xcode/package.xcworkspace
.swiftpm/xcode/package.xcworkspace
 
 
AsyncNetworkService.xcodeproj
AsyncNetworkService.xcodeproj
 
 
AsyncNetworkService
AsyncNetworkService
 
 
AsyncNetworkServiceExample
AsyncNetworkServiceExample
 
 
AsyncNetworkServiceTests
AsyncNetworkServiceTests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Package.swift
Package.swift
 
 
R&PLogo.png
R&PLogo.png
 
 
README.md
README.md
 
 

Repository files navigation

AsyncHTTPNetworkService

AsyncHTTPNetworkService is a Swift native library network layer for using Concurrency (Async/Await).

The goal is to provide a simple network library so you don't have to think about it.

Example use

let networkService = AsyncHTTPNetworkService()
// see below on URLRequestBuilder + URLRequest extension for a easy example creating URL Requests
let urlRequest = URLRequest(...)
let person: Person = try await networkService.requestObject(urlRequest)
// person inherits from Codable

let searchResults: [Results] = try await networkService.requestObjects(urlRequest)

// networkService.requestVoid
// networkService.requestString

Compatibility

AsyncHTTPNetworkService is compatible to iOS 13+. If there are issues surrounding Aync/Await for < iOS 15, please let us know.

URLRequestBuilder + URLRequest extension

AsyncHTTPNetworkService includes URLRequest helpers for ease of creating requests and modifying requests

let baseURL = URLRequestBuilder(baseURL:  URL(string: "someendpoint"))

baseURL.get("user").queryItems(["tag": "check"])
baseURL.post("login").token("accessToken")
baseURL.post("withBody").body(json: codableObject)

Request Modifiers

AsyncNetworkService provides a basic protocol called NetworkRequestModifier that allows you to modify the network request before it sends.

2 options are included in AsyncNetworkService

APIKeyRequestModifier

Use this to pass up an api_key parameter inside a queryItem for all requests. A good example is when you're using a service that requires an api key.

This modifier could easily be updated to add an api_key to the request headers instead

BearerTokenRequestModifier

For each request, this will add in the passed in authenticationToken inside the Authorization header.

Example App

Included in this repo is a SwiftUI example app using AsyncHTTPNetworkService connecting to a Giphy api. Included is showing how using Codable to decode to objects easily.

The network calls to connect to Giphy is layed out in AsyncService.swift

Inside the GiphyService class is a list of Routes that are connected, and a function for each endpoint that is connected.

The init of the GiphyService includes an APIKeyRequestModifier that adds the a api_key to the header on each network request.

Maintainers

Matt Kiazyk

Contact

Made with ❤️ by Robots & Pencils

Twitter | GitHub

About

A Network layer for Swift using Concurrency

Resources

Readme
License
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.