This file contains hidden or 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
| library shelfmiddleware.checktoken; | |
| import 'headers.dart'; | |
| import 'token.dart'; | |
| import 'package:shelf/shelf.dart' as shelf; | |
| final shelf.Middleware checkToken = shelf.createMiddleware(requestHandler: _passOrForbid); | |
| shelf.Response _passOrForbid(shelf.Request request) { |
This file contains hidden or 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
| library shelfmiddleware.cors; | |
| import 'headers.dart'; | |
| import 'package:shelf/shelf.dart' as shelf; | |
| shelf.Middleware addCORSHeaders = shelf.createMiddleware(requestHandler: _options, responseHandler: _cors); | |
| shelf.Response _options(shelf.Request request) => (request.method == 'OPTIONS') ? | |
| new shelf.Response.ok(null, headers: CORSHeader) : null; |
This file contains hidden or 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
| import 'dart:io'; | |
| import '../lib/middleware.dart'; | |
| import '../lib/cors.dart'; | |
| import '../lib/routes.dart'; | |
| import 'package:args/args.dart'; | |
| import 'package:shelf/shelf.dart' as shelf; | |
| import 'package:shelf/shelf_io.dart' as io; |
This file contains hidden or 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
| name: shelfMiddleware | |
| description: Testing how to do some simple stuff with Shelf Middleware | |
| dependencies: | |
| args: any | |
| shelf: any | |
| shelf_route: any |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <testsuite name="All tests" hostname="hostname" tests="12" failures="0" errors="0" skipped="0" time="0.042" timestamp="2014-09-29 17:58:10.534"> | |
| <testcase id="1" name="Testing unknown route GET /unknown -> return 404 Not Found" time="0.019"> | |
| </testcase> | |
| <testcase id="2" name="Testing unknown route PUT /user/1 -> return 404 Not Found" time="0.001"> | |
| </testcase> | |
| <testcase id="3" name="Testing unknown route POST /user/1/name -> return 404 Not Found" time="0.0"> | |
| </testcase> | |
| <testcase id="4" name="Testing route GET /user/42 -> return 404 Not Found" time="0.004"> | |
| </testcase> |
This file contains hidden or 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
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:io' show HttpStatus; | |
| import '../lib/routes.dart'; | |
| import 'package:junitconfiguration/junitconfiguration.dart'; | |
| import 'package:shelf/shelf.dart' as shelf; | |
| import 'package:shelf_exception_response/exception.dart'; | |
| import 'package:shelf_path/shelf_path.dart'; |
This file contains hidden or 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
| library shelftest.handlers; | |
| import 'dart:async'; | |
| import 'dart:convert'; | |
| import 'dart:io' show HttpHeaders; | |
| import 'database.dart'; | |
| import 'user.dart'; | |
| import 'package:shelf_exception_response/exception.dart'; |
This file contains hidden or 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
| library shelftest.routes; | |
| import 'handlers.dart' as handler; | |
| import 'package:shelf_route/shelf_route.dart'; | |
| Router routes = new Router() | |
| ..get('/user/{userid}', handler.getUser) | |
| ..put('/user/{userid}/name', handler.setUserName); |
This file contains hidden or 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
| name: shelfTest | |
| description: Just testing Shelf | |
| dependencies: | |
| junitconfiguration: any | |
| shelf: any | |
| shelf_exception_response: any | |
| shelf_route: any |
This file contains hidden or 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
| import 'dart:io'; | |
| import '../lib/routes.dart'; | |
| import 'package:shelf/shelf.dart' as shelf; | |
| import 'package:shelf/shelf_io.dart' as io; | |
| import 'package:shelf_exception_response/exception_response.dart'; | |
| void main() { | |
| final shelf.Handler handler = const shelf.Pipeline() |