https://github.com/neuroglia-io/workflowcore.http
.NET CORE 3.1 library that defines HTTP workflow steps for the WorkflowCore workflow engine
https://github.com/neuroglia-io/workflowcore.http
aspnetcore dotnet http workflowcore
Last synced: about 1 year ago
JSON representation
.NET CORE 3.1 library that defines HTTP workflow steps for the WorkflowCore workflow engine
- Host: GitHub
- URL: https://github.com/neuroglia-io/workflowcore.http
- Owner: neuroglia-io
- License: gpl-3.0
- Created: 2020-10-23T18:12:27.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-17T11:50:48.000Z (over 5 years ago)
- Last Synced: 2025-02-22T05:47:16.910Z (about 1 year ago)
- Topics: aspnetcore, dotnet, http, workflowcore
- Language: C#
- Homepage:
- Size: 69.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# WorkflowCore.Http
.NET CORE 3.1 library that defines HTTP workflow steps for the [WorkflowCore](https://github.com/danielgerlag/workflow-core/) workflow engine
# Usage
[Nuget Package](https://www.nuget.org/packages/WorkflowCore.Http/)
```
dotnet add package WorkflowCore.Http
```
# Sample code
## Configuration
```C#
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddWorkflow();
services.AddHttpWorkflow();
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IWorkflowHost workflowHost)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseRouting();
app.UseHttpWorkflow();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
workflowHost.Start();
}
}
```
## Workflow usage
```C#
builder.StartWith(context =>
{
Console.WriteLine("Begining saga");
})
.Saga(saga =>
{
saga
.StartWith(context => Console.WriteLine("Saga started"))
.Then(setup =>
{
setup.Input(step => step.Method, data => HttpMethod.Post);
setup.Input(step => step.Uri, data => "http://localhost/workflow/execute");
setup.Input(step => step.RetryPolicy, data => Policy
.Handle(ex => ex.Message.Contains("400"))
.RetryAsync(4, (ex, attempts) => Console.WriteLine($"Attempt n°{attempts}")));
setup.Input(step => step.Content, data => new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, MediaTypeNames.Application.Json));
})
.CompensateWith(setup =>
{
setup.Input(step => step.Method, data => HttpMethod.Get);
setup.Input(step => step.Uri, data => "http://localhost:56832/workflow/compensate");
})
.Then(setup =>
{
setup.Input(step => step.Method, data => HttpMethod.Get);
setup.Input(step => step.Path, data => "/test/go");
})
.Then(context => Console.WriteLine("Saga ended"));
});
```
# Contributing
Please see [CONTRIBUTING.md](https://github.com/neuroglia-io/WorkflowCore.Http/blob/master/CONTRIBUTING.md) for instructions on how to contribute.