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 readingTag: dart-shelf
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 readingHow to serve both dynamic and static pages with Dart and shelf?
Issue Using shelf_static to serve static web pages through Dart is no problem: var staticHandler = createStaticHandler(staticPath, defaultDocument:’home.html’); io.serve(staticHandler, ‘localhost’, port).then((server) { print(‘Serving at http://${server.address.host}:${server.port}’); }); and I can use shelf_route fine for dynamic web pages: Router routes = new
Continue readingHow do I validate an established session using the shelf_auth library?
Issue I’ve been trying to write a simple server that accepts username/password credentials, validates them, then creates a JWT token for the client that they then use to gain access to certain routes. I am able to do everything up
Continue readingHow to serve a polymer application from dart shelf static file handler?
Issue I’m trying to serve a polymer application using a shelf static server. I create next structure: polymerapp – pubspec.yml – bin – server.dart – web – index.html – lib – main_app.dart – main_app.html Inside server.dart I put this code:
Continue readingHow to create/add middleware that adds default headers to each request
Issue How can I add middleware to the shelf pipeline that adds default HTTP headers to each request? Solution Update There is now a pub package to simplify adding CORS headers see https://pub.dartlang.org/packages/shelf_cors Original See also https://groups.google.com/a/dartlang.org/forum/#!topic/cloud/2Vn_IqzGtTc final Map<String, String>
Continue readingAngularDart Transformation/Deployments
Issue I am building a client/server app in Dart using Angular for the front-end and Shelf on the backend. When I do a pub build it generates the javascript for the Dart files as expected but is does not replace
Continue readingServing 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 readingIncompatibility 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 readingincompatibility when running dart rpc and shelf (with shelf_rpc) related to headers which are lists (and not Strings)
Issue incompatibility when running dart rpc and shelf (with shelf_rpc) related to headers which are lists (and not Strings). It seems that there is an incompatibility when running dart rpc and shelf (with shelf_rpc) related to headers which are lists
Continue reading