Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generics to provide an transformer based interface for custom types #1

Closed
wants to merge 1 commit into from

Conversation

kylef
Copy link
Member

@kylef kylef commented Mar 29, 2015

The idea behind this is that we can use Turnstone with custom transformers making it easy to mix and match Turnstone with Nest-based middleware and web frameworks which might use custom types.

Theoretical example:

struct Request {
  let uri:String
  let parameters:[String:String]
}

var turnstone = Turnstone({request in request.uri}, undefined, undefined)

turnstone.addRoute('/questions/{id}') { request in
  let id = request.parameters["id"]
  return Response("Question \(id)")
}

turnstone.route  // takes a "Request" structure and expects a "Response" structure to be returned

@kylef kylef closed this Sep 28, 2015
@kylef kylef deleted the generics branch September 28, 2015 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant