izqui / Taylor

A lightweight library for writing HTTP web servers with Swift
MIT License
926 stars 79 forks source link

[Suggestion] Become Nest Compatible #24

Open Danappelxx opened 8 years ago

Danappelxx commented 8 years ago

Nest is a specification for Swift web-servers to allow them to be interchangeable between different frameworks. Here's the specification itself.

Making Taylor support Nest is a challenge but it would make the code easier to work with in the long run. Obviously Taylor would be quite a few layers above the base Nest specification, but the Nest-compatible methods should still be accessible so that other frameworks built on top of Taylor can access them internally.

Nest's creator (kylef) noted:

I'd imagine that Taylor would be split into two components itself. The underlying server would just offer the Nest interface. The other part would be a micro framework that utilises the Nest compatible interface and provides the interface that Taylor provides.

The most difficult part of implementing the specification would be the fact that the main application function returns the response object synchronously, with no callback involved.

We've discussed the callback system before in issue #12, but didn't really get anywhere. I've been searching for alternatives to how the current system is implemented for a while now, and I've come up with a couple viable ideas which would allow us to be Nest-compatible:

 typealias Handler = (Request, Response) -> (Request, Response)

Tell me what you think! Personally I think the ideas behind Nest are really neat and it would allow frameworks to be built around multiple servers instead of binding to a single one internally - which opens up a huge window of possibilities.

Danappelxx commented 8 years ago

Now that we made Taylor synchronous, this discussion should be revived (started?).