shelf_request_response_2_jsonable_object_utility 1.0.1 copy "shelf_request_response_2_jsonable_object_utility: ^1.0.1" to clipboard
shelf_request_response_2_jsonable_object_utility: ^1.0.1 copied to clipboard

A utility that converts the json request body to a jsonable type and one from a jsonable to a response

A class of conversions between Shelf.Request in instances of jsonable_objects and Shelf.Responses created from jsonable_objects

Usage #

A simple usage example:

Required #

install dependencies with https://pub.dev/packages/jsonable_object

import 'package:shelf_request_response_2_json_utility/shelf_request_response_2_jsonable_object_utility.dart';

class Controller {
  final ShelfRequestResponse2JsonUtility<Person> // Person implements IConvertToJson
  shelfRequestResponse2JsonUtility =
  ShelfRequestResponse2JsonUtility<Person>(PersonFactory());

  @Route.post('/')
  FutureOr<Response> post(Request request) {
    var body = shelfRequestResponse2JsonUtility.body(request);
    return shelfRequestResponse2JsonUtility.ok(body);
  }

  Router get router => _$ControllerRouter(this);
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
125
pub points
0%
popularity

Publisher

unverified uploader

A utility that converts the json request body to a jsonable type and one from a jsonable to a response

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

jsonable_object, shelf

More

Packages that depend on shelf_request_response_2_jsonable_object_utility