Skip to content

Commit

Permalink
Merge pull request dart-lang#19 from jonasfj/test-unrelated-annotation
Browse files Browse the repository at this point in the history
Test that unrelated annotations does not affect code-gen
  • Loading branch information
jonasfj authored Aug 12, 2019
2 parents 213d63a + 563e435 commit aea3117
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkgs/shelf_router_generator/test/server/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'dart:async' show Future, FutureOr;
import 'package:shelf/shelf.dart';
import 'package:shelf_router/shelf_router.dart';
import 'api.dart';
import 'unrelatedannotation.dart';

part 'service.g.dart';

Expand Down Expand Up @@ -51,3 +52,10 @@ class Service {

Router get router => _$ServiceRouter(this);
}

class UnrelatedThing {
@EndPoint.put('/api/test')
Future<Response> unrelatedMethod(Request request) async {
return Response.ok('hello world');
}
}
36 changes: 36 additions & 0 deletions pkgs/shelf_router_generator/test/server/unrelatedannotation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// Annotation for an API end-point.
class EndPoint {
/// HTTP verb for requests routed to the annotated method.
final String verb;

/// HTTP route for request routed to the annotated method.
final String route;

/// Create an annotation that routes requests matching [verb] and [route] to
/// the annotated method.
const EndPoint(this.verb, this.route);

/// Route `GET` requests matching [route] to annotated method.
const EndPoint.get(this.route) : verb = 'GET';

/// Route `HEAD` requests matching [route] to annotated method.
const EndPoint.head(this.route) : verb = 'HEAD';

/// Route `POST` requests matching [route] to annotated method.
const EndPoint.post(this.route) : verb = 'POST';

/// Route `PUT` requests matching [route] to annotated method.
const EndPoint.put(this.route) : verb = 'PUT';

/// Route `DELETE` requests matching [route] to annotated method.
const EndPoint.delete(this.route) : verb = 'DELETE';

/// Route `CONNECT` requests matching [route] to annotated method.
const EndPoint.connect(this.route) : verb = 'CONNECT';

/// Route `OPTIONS` requests matching [route] to annotated method.
const EndPoint.options(this.route) : verb = 'OPTIONS';

/// Route `TRACE` requests matching [route] to annotated method.
const EndPoint.trace(this.route) : verb = 'TRACE';
}

0 comments on commit aea3117

Please sign in to comment.