-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from auth0/add-debug-requests
Add ability to log requests or add hooks on request/response/error
- Loading branch information
Showing
9 changed files
with
214 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Hooks.swift | ||
// Guardian | ||
// | ||
// Created by Hernan Zalazar on 07/06/2018. | ||
// Copyright © 2018 Auth0. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Hook that will be called before request is sent | ||
public typealias RequestHook = (URLRequest) -> () | ||
/// Hook that will be called when a response is received (any status code) along with data (if any) | ||
public typealias ResponseHook = (HTTPURLResponse, Data?) -> () | ||
/// Hook that will be called when request fails with error | ||
public typealias ErrorHook = (Error) -> () | ||
|
||
struct Hooks { | ||
let request: RequestHook? | ||
let response: ResponseHook? | ||
let error: ErrorHook? | ||
|
||
init(request: RequestHook? = nil, response: ResponseHook? = nil, error: ErrorHook? = nil) { | ||
self.request = request | ||
self.response = response | ||
self.error = error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.