Skip to content

Commit 16f797d

Browse files
authored
Merge pull request #3 from CodingAleCR/feature/query-paramters
Feature: Query Parameters.
2 parents 66c519b + f0f3a57 commit 16f797d

17 files changed

+217
-91
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
* Added: Documentation for the example.
6+
17
## 0.0.3
28

39
* Added: Documentation for the example.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# http_interceptor
22

3-
A middleware library that lets you modify requests and responses if desired. Based of on (http_middleware)[https://github.com/TEDConsulting/http_middleware]
3+
A middleware library that lets you modify requests and responses if desired. Based of on [http_middleware](https://github.com/TEDConsulting/http_middleware)
44

55
## Getting Started
66

@@ -52,8 +52,8 @@ class WeatherApiInterceptor implements InterceptorContract {
5252
@override
5353
Future<RequestData> interceptRequest({RequestData data}) async {
5454
try {
55-
data.url = "${data.url}&appid=$OPEN_WEATHER_API_KEY";
56-
data.url = "${data.url}&units=metric";
55+
data.params['appid'] = OPEN_WEATHER_API_KEY;
56+
data.params['units'] = 'metric';
5757
data.headers["Content-Type"] = "application/json";
5858
} catch (e) {
5959
print(e);
@@ -85,7 +85,8 @@ class WeatherRepository {
8585
Future<Map<String, dynamic>> fetchCityWeather(int id) async {
8686
var parsedWeather;
8787
try {
88-
final response = await client.get("$baseUrl/weather?id=$id");
88+
final response =
89+
await client.get("$baseUrl/weather", params: {'id': "$id"});
8990
if (response.statusCode == 200) {
9091
parsedWeather = json.decode(response.body);
9192
} else {
@@ -111,13 +112,11 @@ class WeatherRepository {
111112
112113
113114
Future<Map<String, dynamic>> fetchCityWeather(int id) async {
114-
HttpWithInterceptor http = HttpWithInterceptor.build(
115-
interceptors: [WeatherApiInterceptor()]);
116-
117115
var parsedWeather;
118116
try {
119-
var response = await http.get("$baseUrl/weather?id=$id");
120-
117+
var response = await HttpWithInterceptor.build(
118+
interceptors: [WeatherApiInterceptor()])
119+
.get("$baseUrl/weather", params: {'id': "$id"});
121120
if (response.statusCode == 200) {
122121
parsedWeather = json.decode(response.body);
123122
} else {
@@ -132,5 +131,6 @@ class WeatherRepository {
132131
}
133132
```
134133

135-
### Need help?
134+
### Issue Reporting
135+
136136
Open an issue and tell me, I will be happy to help you out as soon as I can.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
# This is a generated file; do not edit or check into version control.
3+
export "FLUTTER_ROOT=/Users/alejandro/Workspaces/flutter/flutter"
4+
export "FLUTTER_APPLICATION_PATH=/Users/alejandro/Workspaces/codingalecr/http_interceptor/example"
5+
export "FLUTTER_TARGET=/Users/alejandro/Workspaces/codingalecr/http_interceptor/example/lib/main.dart"
6+
export "FLUTTER_BUILD_DIR=build"
7+
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
8+
export "FLUTTER_FRAMEWORK_DIR=/Users/alejandro/Workspaces/flutter/flutter/bin/cache/artifacts/engine/ios"
9+
export "TRACK_WIDGET_CREATION=true"

example/ios/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
66

7+
install! 'cocoapods', :disable_input_output_paths => true
8+
79
project 'Runner', {
810
'Debug' => :debug,
911
'Profile' => :release,

example/ios/Podfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- Flutter (1.0.0)
3+
- http_interceptor (0.0.1):
4+
- Flutter
5+
6+
DEPENDENCIES:
7+
- Flutter (from `.symlinks/flutter/ios`)
8+
- http_interceptor (from `.symlinks/plugins/http_interceptor/ios`)
9+
10+
EXTERNAL SOURCES:
11+
Flutter:
12+
:path: ".symlinks/flutter/ios"
13+
http_interceptor:
14+
:path: ".symlinks/plugins/http_interceptor/ios"
15+
16+
SPEC CHECKSUMS:
17+
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
18+
http_interceptor: 35739d2beb6230e975f7015d7c994ebd4698402f
19+
20+
PODFILE CHECKSUM: 69dacd58e7f88dae6e0d9a63487e87a9fa42b7b5
21+
22+
COCOAPODS: 1.6.1

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1212
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
1313
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14+
3BF671573F6DDF22BE1013F7 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C5E8C8FB27501C433EA495FA /* libPods-Runner.a */; };
1415
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
1516
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1617
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
@@ -37,13 +38,16 @@
3738
/* End PBXCopyFilesBuildPhase section */
3839

3940
/* Begin PBXFileReference section */
41+
126FE52FDFC1BDF665A063F7 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
4042
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
4143
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
44+
23AE0DDE919024A71E32D59E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
4245
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4346
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
4447
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
4548
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4649
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
50+
8AE106199467C91CFDB141F3 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
4751
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
4852
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
4953
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
@@ -53,6 +57,7 @@
5357
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5458
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5559
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
60+
C5E8C8FB27501C433EA495FA /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
5661
/* End PBXFileReference section */
5762

5863
/* Begin PBXFrameworksBuildPhase section */
@@ -62,6 +67,7 @@
6267
files = (
6368
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
6469
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
70+
3BF671573F6DDF22BE1013F7 /* libPods-Runner.a in Frameworks */,
6571
);
6672
runOnlyForDeploymentPostprocessing = 0;
6773
};
@@ -87,7 +93,8 @@
8793
9740EEB11CF90186004384FC /* Flutter */,
8894
97C146F01CF9000F007C117D /* Runner */,
8995
97C146EF1CF9000F007C117D /* Products */,
90-
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
96+
C5C6273DF2640D363291C0BB /* Pods */,
97+
DEDC890A64E743B55DDEB300 /* Frameworks */,
9198
);
9299
sourceTree = "<group>";
93100
};
@@ -123,19 +130,40 @@
123130
name = "Supporting Files";
124131
sourceTree = "<group>";
125132
};
133+
C5C6273DF2640D363291C0BB /* Pods */ = {
134+
isa = PBXGroup;
135+
children = (
136+
126FE52FDFC1BDF665A063F7 /* Pods-Runner.debug.xcconfig */,
137+
23AE0DDE919024A71E32D59E /* Pods-Runner.release.xcconfig */,
138+
8AE106199467C91CFDB141F3 /* Pods-Runner.profile.xcconfig */,
139+
);
140+
name = Pods;
141+
path = Pods;
142+
sourceTree = "<group>";
143+
};
144+
DEDC890A64E743B55DDEB300 /* Frameworks */ = {
145+
isa = PBXGroup;
146+
children = (
147+
C5E8C8FB27501C433EA495FA /* libPods-Runner.a */,
148+
);
149+
name = Frameworks;
150+
sourceTree = "<group>";
151+
};
126152
/* End PBXGroup section */
127153

128154
/* Begin PBXNativeTarget section */
129155
97C146ED1CF9000F007C117D /* Runner */ = {
130156
isa = PBXNativeTarget;
131157
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
132158
buildPhases = (
159+
E6596CFD0A8AB4410DCC306C /* [CP] Check Pods Manifest.lock */,
133160
9740EEB61CF901F6004384FC /* Run Script */,
134161
97C146EA1CF9000F007C117D /* Sources */,
135162
97C146EB1CF9000F007C117D /* Frameworks */,
136163
97C146EC1CF9000F007C117D /* Resources */,
137164
9705A1C41CF9048500538489 /* Embed Frameworks */,
138165
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
166+
76A4C1EFEA83707C69CAB4E4 /* [CP] Embed Pods Frameworks */,
139167
);
140168
buildRules = (
141169
);
@@ -208,6 +236,25 @@
208236
shellPath = /bin/sh;
209237
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
210238
};
239+
76A4C1EFEA83707C69CAB4E4 /* [CP] Embed Pods Frameworks */ = {
240+
isa = PBXShellScriptBuildPhase;
241+
buildActionMask = 2147483647;
242+
files = (
243+
);
244+
inputFileListPaths = (
245+
);
246+
inputPaths = (
247+
);
248+
name = "[CP] Embed Pods Frameworks";
249+
outputFileListPaths = (
250+
);
251+
outputPaths = (
252+
);
253+
runOnlyForDeploymentPostprocessing = 0;
254+
shellPath = /bin/sh;
255+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
256+
showEnvVarsInLog = 0;
257+
};
211258
9740EEB61CF901F6004384FC /* Run Script */ = {
212259
isa = PBXShellScriptBuildPhase;
213260
buildActionMask = 2147483647;
@@ -222,6 +269,28 @@
222269
shellPath = /bin/sh;
223270
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
224271
};
272+
E6596CFD0A8AB4410DCC306C /* [CP] Check Pods Manifest.lock */ = {
273+
isa = PBXShellScriptBuildPhase;
274+
buildActionMask = 2147483647;
275+
files = (
276+
);
277+
inputFileListPaths = (
278+
);
279+
inputPaths = (
280+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
281+
"${PODS_ROOT}/Manifest.lock",
282+
);
283+
name = "[CP] Check Pods Manifest.lock";
284+
outputFileListPaths = (
285+
);
286+
outputPaths = (
287+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
288+
);
289+
runOnlyForDeploymentPostprocessing = 0;
290+
shellPath = /bin/sh;
291+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
292+
showEnvVarsInLog = 0;
293+
};
225294
/* End PBXShellScriptBuildPhase section */
226295

227296
/* Begin PBXSourcesBuildPhase section */

example/ios/Runner.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict/>
5+
</plist>

example/lib/credentials.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Replace this if you are going to run the example. You can get your own at https://openweathermap.org/
2-
const String OPEN_WEATHER_API_KEY = "YOUR-KEY-GOES-HERE";
2+
const String OPEN_WEATHER_API_KEY = "YOUR-KEY-HERE";

0 commit comments

Comments
 (0)