Commit f8ece3f1 authored by 乔金柱's avatar 乔金柱

Merge branch 'houchaoxin/dev' into 'master'

网络请求添加header

See merge request !7
parents 8a1b01ea 59d701f8
...@@ -59,39 +59,45 @@ ...@@ -59,39 +59,45 @@
} }
NSString *fullUrlString = [NSString stringWithFormat:@"%@%@%@", self.apiHost, URLString, self.urlCommonParameters]; 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; __weak typeof(self) weakSelf = self;
if (method == HttpMethodGet) { 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]; [weakSelf successWithTask:task responseObject:responseObject success:success];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[weakSelf failureWithTask:task error:error failed:failed]; [weakSelf failureWithTask:task error:error failed:failed];
}]; }];
}else if (method == HttpMethodPost){ }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]; [weakSelf successWithTask:task responseObject:responseObject success:success];
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[weakSelf failureWithTask:task error:error failed:failed]; [weakSelf failureWithTask:task error:error failed:failed];
}]; }];
}else if (method == HttpMethodDelete){ }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]; [weakSelf successWithTask:task responseObject:responseObject success:success];
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[weakSelf failureWithTask:task error:error failed:failed]; [weakSelf failureWithTask:task error:error failed:failed];
}]; }];
}else if (method == HttpMethodPatch){ }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]; [weakSelf successWithTask:task responseObject:responseObject success:success];
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[weakSelf failureWithTask:task error:error failed:failed]; [weakSelf failureWithTask:task error:error failed:failed];
}]; }];
}else if (method == HttpMethodPut){ }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]; [weakSelf successWithTask:task responseObject:responseObject success:success];
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[weakSelf failureWithTask:task error:error failed:failed]; [weakSelf failureWithTask:task error:error failed:failed];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment