Skip to content

ZewoGraveyard/RecoveryMiddleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RecoveryMiddleware

Swift Zewo Platform License Slack Travis Codebeat

RecoveryMiddleware provides a nice way to recover from errors in your middleware chain.

Usage

import RecoveryMiddleware
import HTTPServer
import Router

enum CustomError: ErrorProtocol {
    case somethingBadHappened
}

let recover = RecoveryMiddleware { error in
	switch error {
	case CustomError.somethingBadHappened:
	    return Response(body: "something bad happened")
	default:
	    return Response(status: .internalServerError)
	}
}

let router = Router(middleware: recover) { route in
	route.get("/") { _ in
		throw CustomError.somethingBadHappened
	}
}

try Server(router).start()

Installation

  • Add RecoveryMiddleware to your Package.swift
import PackageDescription

let package = Package(
	dependencies: [
		.Package(url: "https://github.com/Zewo/RecoveryMiddleware.git", majorVersion: 0, minor: 5),
	]
)

Support

If you need any help you can join our Slack and go to the #help channel. Or you can create a Github issue in our main repository. When stating your issue be sure to add enough details, specify what module is causing the problem and reproduction steps.

Community

Slack

The entire Zewo code base is licensed under MIT. By contributing to Zewo you are contributing to an open and engaged community of brilliant Swift programmers. Join us on Slack to get to know us!

License

This project is released under the MIT license. See LICENSE for details.