-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from utopia-dart/refactor
Utopia HTTP server library
- Loading branch information
Showing
20 changed files
with
349 additions
and
152 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 0.0.1 | ||
## 0.1.0 | ||
|
||
- Initial version. | ||
- Multi threaded HTTP server | ||
- Easy to use | ||
- Customizable | ||
- Inbuilt dependency injection |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,39 @@ | ||
# Utopia Dart Framework | ||
# Utopia HTTP Server | ||
|
||
**NOT READY FOR PRODUCTION** | ||
|
||
Light and Fast Dart Framework to build awesome Dart applications. Inspired from [Utopia PHP Framework](https://github.com/utopia-php/framework). | ||
|
||
## ⚠️ Warning! | ||
|
||
This library is highly volatile and heavily under development. | ||
Light and Fast Dart HTTP library to build awesome Dart server side applications. Inspired from [Utopia PHP ecosystem](https://github.com/utopia-php). | ||
|
||
## Getting Started | ||
|
||
First add the dependency in your pubspec.yaml | ||
|
||
```yaml | ||
dependencies: | ||
utopia_framework: | ||
git: https://github.com/utopia-dart/utopia_framework | ||
utopia_http: ^0.1.0 | ||
``` | ||
Now, in main.dart, you can | ||
```dart | ||
import 'dart:io'; | ||
import 'package:utopia_framework/utopia_framework.dart'; | ||
import 'package:utopia_http/utopia_http.dart'; | ||
|
||
void main() async { | ||
final app = App(); | ||
app | ||
.get('/') | ||
.inject('response') | ||
.action((Response response) { | ||
response.text('Hello World!'); | ||
return response; | ||
}); | ||
|
||
final address = InternetAddress.anyIPv4; | ||
final port = App.getEnv('PORT', 8080); | ||
await App.serve(app, ShelfServer(address, port), threads: 3); | ||
print("server started at ${address.address}:$port"); | ||
print('press any key to exit.'); | ||
stdin.readByteSync(); | ||
final port = Http.getEnv('PORT', 8080); | ||
final app = Http(ShelfServer(address, port), threads: 8); | ||
|
||
app.get('/').inject('request').inject('response').action( | ||
(Request request, Response response) { | ||
response.text('Hello world'); | ||
return response; | ||
}, | ||
); | ||
|
||
await app.start(); | ||
} | ||
|
||
``` | ||
|
||
## Copyright and license | ||
|
||
The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) | ||
The MIT License (MIT) [https://www.opensource.org/licenses/mit-license.php](https://www.opensource.org/licenses/mit-license.php) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
name: utopia_framework_example | ||
name: utopia_http_example | ||
description: A starting point for Dart libraries or applications. | ||
version: 1.0.0 | ||
publish_to: none | ||
# homepage: https://www.example.com | ||
|
||
environment: | ||
sdk: '>=2.17.5 <3.0.0' | ||
sdk: '>=2.17.5 <4.0.0' | ||
|
||
dependencies: | ||
shelf: | ||
utopia_framework: | ||
utopia_http: | ||
path: ../ | ||
|
||
dev_dependencies: | ||
lints: ^2.0.0 | ||
test: ^1.16.0 | ||
lints: ^3.0.0 | ||
test: ^1.25.2 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/// Application mode | ||
enum AppMode { development, stage, production } |
Oops, something went wrong.