All Projects → rhodgkins → Swifthttpstatuscodes

rhodgkins / Swifthttpstatuscodes

Licence: mit
Swift enum wrapper for easier handling of HTTP status codes.

Programming Languages

swift
15916 projects
enum
40 projects

Projects that are alternatives of or similar to Swifthttpstatuscodes

Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-8.81%)
Mutual labels:  tvos, watchos
Berkanansdk
Bluetooth mesh messaging SDK for apps
Stars: ✭ 150 (-5.66%)
Mutual labels:  tvos, watchos
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-25.16%)
Mutual labels:  tvos, watchos
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (-16.98%)
Mutual labels:  tvos, watchos
Opencombine
Open source implementation of Apple's Combine framework for processing values over time.
Stars: ✭ 2,040 (+1183.02%)
Mutual labels:  tvos, watchos
Swiftui Kit
A SwiftUI system components and interactions demo app
Stars: ✭ 1,733 (+989.94%)
Mutual labels:  tvos, watchos
Iconic
🎨 Auto-generated icon font library for iOS, watchOS and tvOS
Stars: ✭ 1,567 (+885.53%)
Mutual labels:  tvos, watchos
Ios Samples
Xamarin.iOS sample apps
Stars: ✭ 1,501 (+844.03%)
Mutual labels:  tvos, watchos
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-13.21%)
Mutual labels:  tvos, watchos
Noticeobservekit
NoticeObserveKit is type-safe NotificationCenter wrapper.
Stars: ✭ 147 (-7.55%)
Mutual labels:  tvos, watchos
Mapboxgeocoder.swift
Address search and reverse geocoding in Swift or Objective-C on iOS, macOS, tvOS, and watchOS
Stars: ✭ 115 (-27.67%)
Mutual labels:  tvos, watchos
Swiftui Shapes
🚀 Collection of SwiftUI shapes
Stars: ✭ 137 (-13.84%)
Mutual labels:  tvos, watchos
Mapbox Directions Swift
Traffic-aware directions and map matching in Swift on iOS, macOS, tvOS, watchOS, and Linux
Stars: ✭ 115 (-27.67%)
Mutual labels:  tvos, watchos
Surmagic
🚀 The better way to deal with Binary Frameworks on iOS, Mac Catalyst, tvOS, macOS, and watchOS. Create XCFrameworks with ease.
Stars: ✭ 119 (-25.16%)
Mutual labels:  tvos, watchos
Articles Zh Hans
Articles for NSHipster.cn
Stars: ✭ 113 (-28.93%)
Mutual labels:  tvos, watchos
Persistencekit
Store and retrieve Codable objects to various persistence layers, in a couple lines of code!
Stars: ✭ 121 (-23.9%)
Mutual labels:  tvos, watchos
Swift Sdk
LeanCloud Swift SDK
Stars: ✭ 110 (-30.82%)
Mutual labels:  tvos, watchos
Diff
Simple diff library in pure Swift
Stars: ✭ 110 (-30.82%)
Mutual labels:  tvos, watchos
Cloudkitgdpr
Framework for allowing users to manage data stored in iCloud
Stars: ✭ 126 (-20.75%)
Mutual labels:  tvos, watchos
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-0.63%)
Mutual labels:  tvos, watchos

SwiftHTTPStatusCodes

Build Status Carthage compatible Pod Version Pod Platform Pod License

Swift enum wrapper for easier handling of HTTP status codes.

The purpose of this library is to improve to clarify of code and remove the need for checking of status codes as numbers (==200), or as a range of values (== 2xx) - instead replacing it with descriptive enums.

All the RF2616 standard status codes are supported with a few added ones from the Wikipedia page.

As of version 3.0.0 of this framework, the list of status codes are directly generated from a online IANA CSV. The HTML page has a last updated field, and this is also mirrored in the header comments to identify which version this framework is currently using.
If this library is out of date compared to this page please open an issue and I will update the list.

Usage

Swift versions support

  • Swift 5.1 - use version 3.3.2
  • Swift 5 - use version 3.3.1
  • Swift 4 - use version 3.3.0
  • Swift 3 - use version 3.1
  • Older versions - use version 3.0

Swift Package Manager

Add this package to the dependencies in your Package.swift file:

.package(url: "https://github.com/rhodgkins/SwiftHTTPStatusCodes.git", .upToNextMajor(from: "3.0.0"))

Carthage

Cartfile:

github "rhodgkins/SwiftHTTPStatusCodes" ~> 3.3

Source code:

import HTTPStatusCodes

CocoaPods

Podfile:

pod 'HTTPStatusCodes', '~> 3.3.0'

Source code:

import HTTPStatusCodes

Manually

Or drop in the Swift files inside the Sources folder into your project.

Helper methods

There are Bool properties on the enum for checking if a status code is of a certain category:

isInformational
isSuccess
isRedirection
isClientError
isServerError

There is also an extension on HTTPURLResponse to obtain a status code enum directly and to init with one:

var statusCodeValue: HTTPStatusCode?
init?(url: URL, statusCode: HTTPStatusCode, httpVersion: String?, headerFields: [String : String]?)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].