Last active
May 16, 2018 21:58
-
-
Save graphicbeacon/c931aa3efe007d001b7b1bf250667be3 to your computer and use it in GitHub Desktop.
Sample code for "Building RESTful Web APIs with Dart, Aqueduct and PostgreSQL (Part 2)" post on Medium (3)
This file contains 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 '../fave_reads.dart'; | |
class BooksController extends HTTPController { | |
// invoked for GET /books | |
@httpGet // HTTPMethod meta data | |
Future<Response> getAllBooks() async => new Response.ok('Showing all books'); | |
// invoked for GET /books/:index | |
@httpGet // HTTPMethod meta data | |
Future<Response> getBook(@HTTPPath("index") int idx) async => new Response.ok('Showing single book'); | |
// invoked for POST /books | |
@httpPost // HTTPMethod meta data | |
Future<Response> addBook() async => new Response.ok('Added a book'); | |
// invoked for PUT /books | |
@httpPut // HTTPMethod meta data | |
Future<Response> updateBook() async => new Response.ok('Updated a book'); | |
// invoked for DELETE /books | |
@httpDelete // HTTPMethod meta data | |
Future<Response> deleteBook() async => new Response.ok('Deleted a book'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment