Created
November 30, 2013 16:14
-
-
Save beyond-code-github/7720973 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ʃ.Route(ʅ => ʅ / "Hello" * Pipeline.Action<FirstComponent>() / ( | |
ʅ / "World" * Pipeline.Action<SecondComponent>() | |
| ʅ / "Foobar" * Pipeline.Action<ThirdComponent>())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirstComponent | |
{ | |
private readonly Func<IDictionary<string, object>, Task> next; | |
public FirstComponent(Func<IDictionary<string, object>, Task> next) | |
{ | |
this.next = next; | |
} | |
public async Task Invoke(IDictionary<string, object> environment) | |
{ | |
await environment.WriteResponse("before#1"); | |
await this.next(environment); | |
await environment.WriteResponse("after#1"); | |
} | |
} | |
public class SecondComponent | |
{ | |
private readonly Func<IDictionary<string, object>, Task> next; | |
public SecondComponent(Func<IDictionary<string, object>, Task> next) | |
{ | |
this.next = next; | |
} | |
public async Task Invoke(IDictionary<string, object> environment) | |
{ | |
await environment.WriteResponse("before#2"); | |
await this.next(environment); | |
await environment.WriteResponse("after#2"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class When_building_a_pipeline_with_options_invoking_the_first : When_building_a_pipeline_with_options | |
{ | |
private Because of = () => responseMessage = client.GetAsync("http://localhost/Hello/World").Result; | |
private It should_execute_the_final_function = () => responseMessage.Content.ReadAsStringAsync().Result.ShouldEqual("before#1before#2after#2after#1"); | |
private It should_return_200 = () => responseMessage.StatusCode.ShouldEqual(HttpStatusCode.OK); | |
} | |
public class When_building_a_pipeline_with_options_invoking_the_second : When_building_a_pipeline_with_options | |
{ | |
private Because of = () => responseMessage = client.GetAsync("http://localhost/Hello/Foobar").Result; | |
private It should_execute_the_final_function = () => responseMessage.Content.ReadAsStringAsync().Result.ShouldEqual("before#1before#3after#3after#1"); | |
private It should_return_200 = () => responseMessage.StatusCode.ShouldEqual(HttpStatusCode.OK); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment