-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fix second instance api url
- Loading branch information
Showing
6 changed files
with
47 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
class InternalRouteRequest { | ||
const InternalRouteRequest({ | ||
class InternalRouteUri { | ||
const InternalRouteUri({ | ||
required this.path, | ||
required this.queries, | ||
required this.hash, | ||
}); | ||
|
||
factory InternalRouteRequest.fromUri(final Uri uri) => InternalRouteRequest( | ||
factory InternalRouteUri.fromUri(final Uri uri) => InternalRouteUri( | ||
path: uri.path, | ||
queries: uri.queryParameters, | ||
hash: uri.fragment, | ||
); | ||
|
||
factory InternalRouteRequest.fromRawPath(final String path) => | ||
InternalRouteRequest.fromUri(Uri.parse('http://localhost$path')); | ||
factory InternalRouteUri.fromRawPath(final String path) => | ||
InternalRouteUri.fromUri(Uri.parse('http://localhost$path')); | ||
|
||
final String path; | ||
final Map<String, String> queries; | ||
final String hash; | ||
|
||
@override | ||
String toString() { | ||
final StringBuffer output = StringBuffer(path); | ||
if (queries.isNotEmpty) { | ||
output.write('?'); | ||
queries.forEach((final String k, final String v) { | ||
output.write('$k=${Uri.encodeQueryComponent(v)}'); | ||
}); | ||
} | ||
if (hash.isNotEmpty) { | ||
output.write('#${Uri.encodeQueryComponent(hash)}'); | ||
} | ||
return output.toString(); | ||
} | ||
} | ||
|
||
abstract class InternalRoute { | ||
bool matches(final InternalRouteRequest req); | ||
Future<void> handle(final InternalRouteRequest req); | ||
bool matches(final InternalRouteUri uri); | ||
Future<void> handle(final InternalRouteUri uri); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters