Comments (5)
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.
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.
Stencil parsing added in 0.1.8
from vapor.
@tannernelson vapor had stopped support for stencil template?
from vapor.
@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)
- URI semantics are broken HOT 1
- commรนit
- Double slash in URLs still breaks route matching with variable parts in vapor 4.92.0 HOT 2
- Trying to build on Ubuntu 20 with swift run and getting Building for debugging... error: emit-module command failed due to signal 9 HOT 2
- Unable to shutdown server HOT 1
- Title
- Vapor URLQueryContainer no longer supports valueless query parameters HOT 4
- Swift Vapor-Save records in Mysql JSON data type during mapping with swift get error- Could not convert MySQL data to String: <MYSQL_TYPE_JSON HOT 6
- Large, streamed request body may result in noSignalReceived preconditionFailure crash HOT 6
- Websocket shouldUpgrade() fail causes empty reply from server HOT 4
- Cannot setup a route returning `[Int: String]` HOT 7
- Log actual port when it's picked by the OS
- 'Flag' URL Query params don't decode into structs HOT 3
- HEAD response should allow non-zero Content-Length HOT 3
- Authentication Cache + Storage crash application HOT 2
- Default to `HTTPClient.shared` when possible HOT 1
- URLFormEncoder does not escape all reserved characters HOT 3
- Return 415 error if compressed request is detected, but not supported
- Crash after installing posix ELG as concurrency executor HOT 1
- Stored property '_id' of 'Sendable'-conforming class 'Todo' is mutable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vapor.