Skip to content

Commit 7d73e80

Browse files
init
0 parents  commit 7d73e80

8 files changed

+613
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
- Initial version.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Simple REST api server implemented in Dart
2+
3+
# Installation
4+
5+
You will need to have dart installed https://dart.dev/get-dart
6+
7+
# Running the server
8+
9+
`dart run`
10+
11+
# Running tests
12+
13+
`dart test`

analysis_options.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

bin/server.dart

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'dart:io';
2+
import 'package:shelf/shelf.dart';
3+
import 'package:shelf/shelf_io.dart' as io;
4+
5+
const i = 0;
6+
void main() async {
7+
final handler =
8+
const Pipeline().addMiddleware(logRequests()).addHandler(echoRequest);
9+
10+
final server = await io.serve(handler, InternetAddress.anyIPv4, 4001);
11+
print('Serving at http://${server.address.host}:${server.port}');
12+
}
13+
14+
Response echoRequest(Request request) {
15+
if (request.url.path == '/' || request.url.path == '') {
16+
return Response.ok('Server is up and running');
17+
} else {
18+
return Response.notFound('Not found');
19+
}
20+
}

0 commit comments

Comments
 (0)