Code Monkey home page Code Monkey logo

dia_body's Introduction

Hi there ๐Ÿ‘‹ I`m Andrey Unger

  • โœจ Iโ€™m full-stack developer.
  • ๐Ÿ’ช More than twenty years of development experience

Work with:

  • Backend - NodeJS, Go, Dart
  • Frontend - React, Flutter
  • Mobile - Flutter
  • Game - Unity3D, Flutter, Flame

Top Langs

My stats

GitHub Streak Anurag's GitHub stats score

Mastodon

dia_body's People

Contributors

unger1984 avatar

Stargazers

 avatar

Watchers

 avatar

dia_body's Issues

Simple Example using both dia_router and dia_body

Hi
I've been trying to get your example code working. If I provide the request body as a JSON string how do I access this data in a route? The sample code you provide outputs nothing to the browser, I was expecting to see the data in the ctx.parsed property.

Perhaps some documentation would make things easier to understand.

When I try to combine this with dia_router the code won't run, see my attempt below.

import 'dart:io';

import 'package:dia/dia.dart' as dia;
import 'package:dia_router/dia_router.dart' as dia_router;
import 'package:dia_body/dia_body.dart';

/// Custom Context with Routing mixin
class ContextWithRouting extends dia.Context with dia_router.Routing, ParsedBody {
  ContextWithRouting(HttpRequest request) : super(request);
}

main() async {

  final app = dia.App((req)=>ContextWithRouting(req));

  app.use(body());
  
  final router = dia_router.Router('');

  router.post('/', (ctx,next) async {
    ctx.body = ''' 
      query=${ctx.query}
      parsed=${ctx.parsed}
      files=${ctx.files}
    ''';
  });
  
  app.use(router.middleware);

  await app.listen('0.0.0.0', 8080);
  print('web server running');

}

When I run this I get the following output:

post.dart:27:18: Error: The getter 'parsed' isn't defined for the class 'Routing'.
 - 'Routing' is from 'package:dia_router/src/routing_mixin.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dia_router-0.1.6/lib/src/routing_mixin.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'parsed'.
    parsed=${ctx.parsed}
                 ^^^^^^
post.dart:28:17: Error: The getter 'files' isn't defined for the class 'Routing'.
 - 'Routing' is from 'package:dia_router/src/routing_mixin.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dia_router-0.1.6/lib/src/routing_mixin.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'files'.
    files=${ctx.files}

Any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.