Skip to content

Commit

Permalink
add cookies and signed cookies on application controller
Browse files Browse the repository at this point in the history
  • Loading branch information
codekeyz committed Dec 21, 2023
1 parent e79ae88 commit 6c294a6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions yaroo/lib/http/http.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ignore_for_file: camel_case_types

import 'dart:async';
import 'dart:io';

import 'package:yaroo/src/_reflector/reflector.dart';
import 'package:yaroo/src/core.dart';
Expand Down Expand Up @@ -28,22 +27,28 @@ abstract class ApplicationController extends AppInstance {

Map<String, dynamic> get params => request.params;

Map<String, dynamic> get query => request.query;
Map<String, dynamic> get queryParams => request.query;

Map<String, dynamic> get headers => request.headers;

Session? get session => request.session;

List<Cookie> get cookies => request.cookies;

List<Cookie> get signedCookies => request.signedCookies;

get body => request.body;

Response badRequest([String? message]) {
const status = 422;
if (message == null) return response.status(status);
return response.json({'message': message}, statusCode: status);
return response.json({'error': message}, statusCode: status);
}

Response notFound([String? message]) {
const status = 404;
if (message == null) return response.status(status);
return response.json({'message': message}, statusCode: status);
return response.json({'error': message}, statusCode: status);
}

Response jsonResponse(data, {int statusCode = 200}) {
Expand Down

0 comments on commit 6c294a6

Please sign in to comment.