-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Marlon Carvalho edited this page Jul 17, 2015
·
9 revisions
Darter is available as a Pub package at Pub. All you have to do is add Darter as a dependency in your project. But first, lets start creating our project:
- Create a new directory named mydarter.
- In this directory, create a file named pubspec.yaml and put the code above inside it.
name: beer
version: 0.0.1
author: Your Name
description: API for exposing beer data.
homepage: Your Homepage
environment:
sdk: '>=1.8.3 <2.0.0'
dependencies:
collection: '>=1.1.1 <2.0.0'
darter: '0.0.1.beta'
- Run
pub get
to update your project dependencies - Create a file named
main.dart
in the project's main directory. - Add the following code to this file.
library beer;
import 'package:darter/darter.dart';
@API(path: 'beers')
class BeerAPI {
@GET()
List get() {
return ["Beer 1", "Beer 2"];
}
}
main() {
new DarterServer()
..addApi(new BeerAPI())
..start();
}
Now, in the command line, just type dart main.dart
. Open your favorite browser and point it to the address http://localhost:8080/beers
. It's up and running! Now, navigate through our documentation to understand how it works and how to create powerful APIs using advanded features.