Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
GMNetService
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMNetService
Commits
f8ece3f1
Commit
f8ece3f1
authored
Sep 24, 2020
by
乔金柱
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'houchaoxin/dev' into 'master'
网络请求添加header See merge request
!7
parents
8a1b01ea
59d701f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
WMNetService.m
GMNetService/Classes/WMNetService.m
+12
-6
No files found.
GMNetService/Classes/WMNetService.m
View file @
f8ece3f1
...
...
@@ -59,39 +59,45 @@
}
NSString
*
fullUrlString
=
[
NSString
stringWithFormat
:
@"%@%@%@"
,
self
.
apiHost
,
URLString
,
self
.
urlCommonParameters
];
NSDictionary
*
dict
;
BOOL
isOpenDebug
=
[[
NSUserDefaults
standardUserDefaults
]
boolForKey
:
@"isOpenDebug"
];
if
(
isOpenDebug
)
{
dict
=
@{
@"X-GM-TEST"
:
@"true"
};
}
else
{
dict
=
@{
@"X-GM-TEST"
:
@"false"
};
}
__weak
typeof
(
self
)
weakSelf
=
self
;
if
(
method
==
HttpMethodGet
)
{
[
networking
GET
:
fullUrlString
parameters
:
parameters
headers
:
nil
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
id
_Nullable
responseObject
)
{
[
networking
GET
:
fullUrlString
parameters
:
parameters
headers
:
dict
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
id
_Nullable
responseObject
)
{
[
weakSelf
successWithTask
:
task
responseObject
:
responseObject
success
:
success
];
}
failure
:^
(
NSURLSessionDataTask
*
_Nullable
task
,
NSError
*
_Nonnull
error
)
{
[
weakSelf
failureWithTask
:
task
error
:
error
failed
:
failed
];
}];
}
else
if
(
method
==
HttpMethodPost
){
[
networking
POST
:
fullUrlString
parameters
:
parameters
headers
:
nil
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
networking
POST
:
fullUrlString
parameters
:
parameters
headers
:
dict
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
weakSelf
successWithTask
:
task
responseObject
:
responseObject
success
:
success
];
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
[
weakSelf
failureWithTask
:
task
error
:
error
failed
:
failed
];
}];
}
else
if
(
method
==
HttpMethodDelete
){
[
networking
DELETE
:
fullUrlString
parameters
:
parameters
headers
:
nil
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
networking
DELETE
:
fullUrlString
parameters
:
parameters
headers
:
dict
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
weakSelf
successWithTask
:
task
responseObject
:
responseObject
success
:
success
];
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
[
weakSelf
failureWithTask
:
task
error
:
error
failed
:
failed
];
}];
}
else
if
(
method
==
HttpMethodPatch
){
[
networking
PATCH
:
fullUrlString
parameters
:
parameters
headers
:
nil
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
networking
PATCH
:
fullUrlString
parameters
:
parameters
headers
:
dict
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
weakSelf
successWithTask
:
task
responseObject
:
responseObject
success
:
success
];
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
[
weakSelf
failureWithTask
:
task
error
:
error
failed
:
failed
];
}];
}
else
if
(
method
==
HttpMethodPut
){
[
networking
PUT
:
fullUrlString
parameters
:
parameters
headers
:
nil
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
networking
PUT
:
fullUrlString
parameters
:
parameters
headers
:
dict
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
weakSelf
successWithTask
:
task
responseObject
:
responseObject
success
:
success
];
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
[
weakSelf
failureWithTask
:
task
error
:
error
failed
:
failed
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment