Code Monkey home page Code Monkey logo

Comments (5)

kdawgwilk avatar kdawgwilk commented on May 4, 2024

This seems like a great place to bring up middleware support for vapor.

Would we want support for adding middleware to:
- All requests
- A single route
- A group of routes

The Bootstrap class seems to be the place where middleware will hook into request and response to process what it needs to then pass it on. The problem I see is that in order to add support for multiple layers of middleware we would also need access to the next middleware in line inside both methods of Bootstrap. Also how middleware is ordered as it comes in from the request versus going out in the response should be decided.

Some links to where my thoughts/ideas are coming from:

SlimPHP's middleware docs
Lumen's middleware docs

from vapor.

tanner0101 avatar tanner0101 commented on May 4, 2024

I'm working on an update that replaces Bootstrap and adds a protocol called Middleware.

This will be in release 0.1.7.

The protocol looks like this

public protocol Middleware {
    func handle(handler: Request -> Response) -> (Request -> Response)   
}

And before the response is delivered in Server.swift

for middleware in self.middleware {
      handler = middleware.handle(handler)
}

from vapor.

tanner0101 avatar tanner0101 commented on May 4, 2024

Stencil parsing added in 0.1.8

from vapor.

yudun1989 avatar yudun1989 commented on May 4, 2024

@tannernelson vapor had stopped support for stencil template?

from vapor.

loganwright avatar loganwright commented on May 4, 2024

@yudun1989 the efforts required to run stencil on Linux were insurmountable for a long time w/o maintaining multiple forks in the dependency chain of Stencil. I'm not sure the current Linux status, but if it's improved, making a 3rd party stencil provider shouldn't be too difficult.

Unfortunately, these 3rd party renderers were requiring too much dev time internally, so it's very unlikely that we'll open up official support any time soon.

Hopefully this answers your question, and happy to open a discussion further if you'd like ๐Ÿ‘

from vapor.

Related Issues (20)

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.