Skip to content

Commit

Permalink
release:v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
iyifr committed Aug 21, 2024
1 parent e470eb7 commit 56195a8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 0.1.3

- ### Patch Release
- Deprecated app.onRequest() signature for registering middleware.
- Added new signature for adding middleware to requests.
```dart
var app = createApp(
port: 5173,
onRequest: (event) => {},
onError: (error, stacktrace, event) => {},
afterResponse: (event) => {},
);
var router = createRouter();
app.use(router);
```
- Error handling in async handlers has been refactored and improved.
- Certain edge cases with wildcard routing patterns were addressed.
- Stream (SSE) implementation removed for now to study StreamSinks.

## 0.1.2

- ### Patch Release
Expand Down
7 changes: 5 additions & 2 deletions bin/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import 'dart:io';
import 'dart:math';

import 'package:h4/create.dart';
import 'package:h4/src/logger.dart';
import 'package:h4/utils/get_header.dart';
import 'package:h4/utils/get_query.dart';
import 'package:h4/utils/read_request_body.dart';
import 'package:h4/utils/set_response_header.dart';

void main(List<String> arguments) async {
var router = createRouter();


var app = createApp(
port: 5173,
onRequest: (event) => {},
onError: (error, stacktrace, event) => {},
afterResponse: (event) => {},
);

var router = createRouter();
app.use(router);

router.post("/vamos/:id/**", (event) async {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ class H4Event {

// Handle non-async handler.
_resolveRequest(this, handlerResult);

if (middlewares?['afterResponse'] != null) {
if (middlewares?['afterResponse']?.left != null) {
middlewares?['afterResponse']?.left!(this);
}
}
}

void _writeToClient(dynamic value) {
Expand Down

0 comments on commit 56195a8

Please sign in to comment.