Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AppleLibs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ullerich
AppleLibs
Commits
8149aac7
Commit
8149aac7
authored
3 years ago
by
Tobias Ullerich
Browse files
Options
Downloads
Patches
Plain Diff
Add HostCallback
parent
777aa406
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
AppleLibs/Network/Requests/DataManager.swift
+10
-3
10 additions, 3 deletions
AppleLibs/Network/Requests/DataManager.swift
with
10 additions
and
3 deletions
AppleLibs/Network/Requests/DataManager.swift
+
10
−
3
View file @
8149aac7
...
@@ -47,8 +47,10 @@ public class DataManager: NSObject, URLSessionDelegate
...
@@ -47,8 +47,10 @@ public class DataManager: NSObject, URLSessionDelegate
}
}
}
}
public
typealias
HostCallback
=
()
->
Host
private
let
timeout
:
TimeInterval
private
let
timeout
:
TimeInterval
public
private(set)
var
host
:
Host
public
private(set)
var
host
Callback
:
HostCallback
private
lazy
var
urlSession
:
URLSession
=
{
private
lazy
var
urlSession
:
URLSession
=
{
URLSession
(
configuration
:
.
default
,
delegate
:
self
,
delegateQueue
:
OperationQueue
.
main
)
URLSession
(
configuration
:
.
default
,
delegate
:
self
,
delegateQueue
:
OperationQueue
.
main
)
...
@@ -59,8 +61,12 @@ public class DataManager: NSObject, URLSessionDelegate
...
@@ -59,8 +61,12 @@ public class DataManager: NSObject, URLSessionDelegate
public
var
delegate
:
DataManagerDelegate
?
public
var
delegate
:
DataManagerDelegate
?
public
init
(
host
:
Host
,
responseOkFilter
:
HttpSuccessFilter
,
responseFilters
:
[
Int
:
HttpResponseFilter
]
=
[:],
timeout
:
TimeInterval
=
10.0
)
{
public
convenience
init
(
host
:
Host
,
responseOkFilter
:
HttpSuccessFilter
,
responseFilters
:
[
Int
:
HttpResponseFilter
]
=
[:],
timeout
:
TimeInterval
=
10.0
)
{
self
.
host
=
host
self
.
init
(
hostCallback
:
{
host
},
responseOkFilter
:
responseOkFilter
,
responseFilters
:
responseFilters
,
timeout
:
timeout
)
}
public
required
init
(
hostCallback
:
@escaping
HostCallback
,
responseOkFilter
:
HttpSuccessFilter
,
responseFilters
:
[
Int
:
HttpResponseFilter
]
=
[:],
timeout
:
TimeInterval
=
10.0
)
{
self
.
hostCallback
=
hostCallback
self
.
responseOkFilter
=
responseOkFilter
self
.
responseOkFilter
=
responseOkFilter
self
.
responseFilters
=
responseFilters
self
.
responseFilters
=
responseFilters
self
.
timeout
=
timeout
self
.
timeout
=
timeout
...
@@ -68,6 +74,7 @@ public class DataManager: NSObject, URLSessionDelegate
...
@@ -68,6 +74,7 @@ public class DataManager: NSObject, URLSessionDelegate
}
}
public
func
url
(
username
:
String
=
""
,
password
:
String
=
""
,
path
:
String
)
->
String
{
public
func
url
(
username
:
String
=
""
,
password
:
String
=
""
,
path
:
String
)
->
String
{
let
host
=
hostCallback
()
var
url
:
String
=
host
.
protocol
var
url
:
String
=
host
.
protocol
if
!
username
.
isEmpty
||
!
password
.
isEmpty
{
if
!
username
.
isEmpty
||
!
password
.
isEmpty
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment