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

Build on top of OWIN with Agent Routing #16

Closed
wants to merge 12 commits into from
Closed

Build on top of OWIN with Agent Routing #16

wants to merge 12 commits into from

Conversation

panesofglass
Copy link
Contributor

This is a shift in thinking from being buddy-buddy with Web API to simply using System.Net.Http types.

Benefits:

  1. Can now deploy Client profile .NET 4.0 and probably as a portable library
  2. Less Web API complexity
  3. Get back to original ideas in Frank of using Rx/Agents

Cons:

  1. Lose the Web API ecosystem
  2. Must manually map to OWIN

To really work, this needs a type provider for the routing. However, I can implement a close approximation, which is in progress in this commit.

Note: not all the samples work.

// TODO: Create a ResourceManager or some form of Supervisor to serve as the App.
// Example:

type App () as x =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generalize this into a Supervisor type. This could implement IDictionary<string, Resource> to provide a somewhat similar API to the suggested type provider.

In order to make this work, I will need to build an internal DSL to mimic the route specification. Something like the following might do:

type UriSegmentTemplate = string // Possibly something more complex
type RouteDef = UriSegmentTemplate * HttpMethod list
type RouteSpec =
    | RouteNode of RouteDef * RouteDef list
    | RouteLeaf of RouteDef
// Need a module to recurse this tree, create Resource instances from RouteDefs, and hook them to their Supervisor.


/// Defines the route for a specific resource
type RouteDef<'T> = 'T * UriRouteTemplate * HttpMethod list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented the proposed RouteDef and RouteSpec as a data structure for communicating intended routes. The current implementation uses a discriminated union to strongly type access to the routes and a simple string for specifying route templates. The route templates are composed as the tree is composed.

let app = new ResourceManager<Routes>(spec)
let resource = app.[Root]
do resource.SetHandler <| get helloWorld
do resource.SetHandler <| post echo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of configuring Resources with the ResourceManager.

@panesofglass
Copy link
Contributor Author

Does it make sense to put this here or in dyfrig?

@panesofglass
Copy link
Contributor Author

I pulled this out as a separate project to determine how well it might work as a framework agnostic library. See the current status at the Taliesin project. My chief concern is that it uses a lot of generics. Extension interfaces would really help here, as would a true type provider, though I don't know how a Type Provider would adapt to framework types.

@panesofglass
Copy link
Contributor Author

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.

1 participant