froggy-docs 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/froggy-docs CHANGED
Binary file
@@ -154,29 +154,34 @@ Router get _router {
154
154
  try {
155
155
  final targetUrl = '$_proxyUrl/api/$path';
156
156
  final method = request.method;
157
- final headers = <String, String>{};
158
-
157
+
158
+ final client = http.Client();
159
+ http.Request req;
160
+
161
+ if (method == 'GET' || method == 'HEAD') {
162
+ req = http.Request(method, Uri.parse(targetUrl));
163
+ } else {
164
+ final body = await request.readAsString();
165
+ req = http.Request(method, Uri.parse(targetUrl));
166
+ if (body.isNotEmpty) {
167
+ req.body = body;
168
+ }
169
+ }
170
+
159
171
  request.headers.forEach((key, value) {
160
172
  if (key.toLowerCase() != 'host') {
161
- headers[key] = value;
173
+ req.headers[key] = value;
162
174
  }
163
175
  });
164
176
 
165
- String? body;
166
- if (method != 'GET' && method != 'HEAD') {
167
- body = await request.readAsString();
168
- }
169
-
170
- final proxyResponse = await http.Request(method, Uri.parse(targetUrl))
171
- .send();
172
-
173
- final responseBody = await proxyResponse.stream.bytesToString();
177
+ final streamedResponse = await client.send(req);
178
+ final responseBody = await streamedResponse.stream.bytesToString();
174
179
 
175
180
  return Response(
176
- proxyResponse.statusCode,
181
+ streamedResponse.statusCode,
177
182
  body: responseBody,
178
183
  headers: {
179
- 'Content-Type': proxyResponse.headers['content-type'] ?? 'application/json',
184
+ 'Content-Type': streamedResponse.headers['content-type'] ?? 'application/json',
180
185
  ..._corsHeaders,
181
186
  },
182
187
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froggy-docs",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Auto-generate API documentation from code annotations. Works with any programming language.",
5
5
  "author": "Kaung Mrat Thu <kaungmyatthuu.dev@gmail.com>",
6
6
  "homepage": "https://github.com/Kaung-Myat/froggydocs",