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 readingTag: dart-shelf
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 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 readingDart Server Side: Where are the advantage of using Shelf rather than IO as a Web Server?
Issue I want to use the RPC library to develop Dart server side Restful. In the library repository, it bring two exemples how to use (https://github.com/dart-lang/rpc-examples/tree/master/bin): Shelf and IO. I would like to understand better the differences between Shelf and
Continue readingDart: Add a middleware to parse to JSON work with shelf_rest
Issue I’ve created a function that converts a model into JSON using mirror. Map convertObjectToJson(Object obj); dynamic convertJsonToObject(Map json, Type type); I wish to use it so that my models/view-models are converted back and forth between request/response so that I
Continue readingSeparating a Cascade in Dart
Issue I’m seeing some weird behavior in Dart. My goal is to only serve static assets if a build/web Dir exists. 1- The following works: Cascade cc; if(new Directory(buildPath).existsSync() ) { cc = new Cascade().add(apiHandler).add(fHandler); } else { cc =
Continue readingUnit testing with dart's shelf_rest
Issue I’m trying to test a Dart REST app run on shelf_rest. Assuming a setup similar to the shelf_rest example, how can one test the configured routes without actually running an HTTP server? import ‘package:shelf/shelf.dart’; import ‘package:shelf/shelf_io.dart’ as io; import
Continue readingHow can I cancel/abort a zone in Dart?
Issue I have an http web server that I’m trying to detect long-running requests and abort them. The following code successfully returns to the client upon timeout, but the async zone still continues to run to completion. How can I
Continue readingServer response with output from Future Object
Issue i created a async/await function in another file thus its handler is returning a Future Object. Now i can’t understand how to give response to client with content of that Future Object in Dart. I am using basic dart
Continue readingDart shelf – Middleware and handler execution order
Issue I’m lost trying to understand how Dart shelf executes the middleware and handlers. From all the documentation I have read (and briefing it up) if you write a Middleware that returns null, then the execution goes down the pipeline.
Continue reading