Giter VIP home page Giter VIP logo

Comments (5)

mikeal avatar mikeal commented on July 19, 2024

i'd rather rip all the middleware out.

we should just implement JSON support inline, it already requires specifial hooks outside of the "middleware" stuff.

from tako.

isaacs avatar isaacs commented on July 19, 2024

Hm. Yeah, I guess you can just do exactly the same thing by listening to app.on("request", myMiddlewareBits).

That still doesn't make it possible to attach filters, though. I suppose you could probably do something like this:

var s = req.socket
var f = zlib.Unzip()
s.pipe(f)
req.socket = f

var s = res.socket
var f = zlib.Gzip()
f.pipe(s)
res.socket = f

but that's of course getting super overly familiar with implementation internals.

from tako.

mikeal avatar mikeal commented on July 19, 2024

yup, the only thing the framework needs hooks for are conditions that will require IO to complete and might need to be required for a route.

auth is one, sessions are another. I want to change the way auth is implemented in to a more generic "condition" system we can use for sessions and other things.

from tako.

isaacs avatar isaacs commented on July 19, 2024

But, no, you could still do json support as a purely external middleware thing if you could attach filters. Just define a stream filter that takes in Objects and spits out JSON, and another that takes JSON and spits out objects. The only other part is setting the content-type and accept headers appropriately.

from tako.

kesla avatar kesla commented on July 19, 2024

Hi!

I've implemented a gzip-middleware for tako https://github.com/kesla/tako-gzip. The suggested code that @isaacs wrote earlier doesn't work, since that gzips the headers also.
Instead I overwrote the _work and _end-methods in the response...
Heavily dependent on implementation internails...

from tako.

Related Issues (13)

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.