dart, shelf_route: What is route name in the `GET` method that work with the request that using multi parameter?

Issue My flutter app sends the request to this API with the GET method and uses the queryParameters like this: Map<String, dynamic> parameters = {‘id’: null}; parameters.updateAll((key, value) => Uri.encodeComponent(jsonEncode(value))); String url= ‘http://localhost:8080/test; final Uri uri = Uri.parse(url).replace(queryParameters: parameters); final

Continue reading

How can I use shelf_web_socket to listen for http and ws requests on the same port

Issue https://pub.dartlang.org/packages/shelf_web_socket shows this example import ‘package:shelf/shelf_io.dart’ as shelf_io; import ‘package:shelf_web_socket/shelf_web_socket.dart’; void main() { var handler = webSocketHandler((webSocket) { webSocket.listen((message) { webSocket.add(“echo $message”); }); }); shelf_io.serve(handler, ‘localhost’, 8080).then((server) { print(‘Serving at ws://${server.address.host}:${server.port}’); }); } I would like to know how

Continue reading

Serving content dynamically using the directory parameter for GET requests – shelf package dart

Issue The code snippets below come from a server serving a get request Server snippets 1) io.serve(handler, InternetAddress.LOOPBACK_IP_V4, 8080).then((server) { print(‘Listening on port 8080’); }).catchError((error) => print(error)); 2) Router routes = new Router() ..get(‘/newest’, handler.handleNewest) ..get(‘/anonymous’, handler.handleAnonymousGetRequest) ..post(‘/anonymous’, handler.handleAnonymousPostRequest); 3)

Continue reading

Incompatibility between the Dart shelf and rpc packages? ('access-control-request-method' header)

Issue There seems to be an incompatibility between the shelf and rpc packages. In rpc [0.4.1] config/api.dart: The handleHttpOptionsRequest expects the ‘access-control-request-method’ header to be a List: Future<HttpApiResponse> handleHttpOptionsRequest( ParsedHttpApiRequest request) async { var requestedHttpMethods = request.headers[‘access-control-request-method’]; List<String> allowed =

Continue reading