Rename HttpRequestReceived to HttpEndpoint

This commit is contained in:
Sipke Schoorstra 2021-03-01 21:10:40 +01:00
parent ec12edd129
commit 33ea486901
22 changed files with 105 additions and 105 deletions

View file

@ -17,16 +17,16 @@ namespace Elsa.Activities.Http
{
[Trigger(
Category = "HTTP",
DisplayName = "Receive HTTP Request",
Description = "Receive an incoming HTTP request.",
DisplayName = "HTTP Endpoint",
Description = "Handle an incoming HTTP request.",
Outcomes = new[] { OutcomeNames.Done }
)]
public class HttpRequestReceived : Activity
public class HttpEndpoint : Activity
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IEnumerable<IHttpRequestBodyParser> _parsers;
public HttpRequestReceived(
public HttpEndpoint(
IHttpContextAccessor httpContextAccessor,
IEnumerable<IHttpRequestBodyParser> parsers)
{

View file

@ -0,0 +1,41 @@
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Elsa.Builders;
using Elsa.Services.Models;
using Microsoft.AspNetCore.Http;
// ReSharper disable ExplicitCallerInfoArgument
// ReSharper disable once CheckNamespace
namespace Elsa.Activities.Http
{
public static class HttpEndpointBuilderExtensions
{
public static IActivityBuilder HttpEndpoint(this IBuilder builder, Action<ISetupActivity<HttpEndpoint>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.Then(setup, null, lineNumber, sourceFile);
public static IActivityBuilder HttpEndpoint(this IBuilder builder, Func<ActivityExecutionContext, ValueTask<PathString>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpEndpoint(this IBuilder builder, Func<ActivityExecutionContext, PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpEndpoint(this IBuilder builder, Func<ValueTask<PathString>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpEndpoint(this IBuilder builder, Func<PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpEndpoint(this IBuilder builder, PathString path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder ReceiveHttpPostRequest<T>(this IBuilder builder, Func<ActivityExecutionContext, PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(activity => activity.WithPath(path).WithMethod(HttpMethods.Post).WithTargetType<T>(), lineNumber, sourceFile);
public static IActivityBuilder ReceiveHttpPostRequest<T>(this IBuilder builder, Func<PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(activity => activity.WithPath(path).WithMethod(HttpMethods.Post).WithTargetType<T>(), lineNumber, sourceFile);
public static IActivityBuilder ReceiveHttpPostRequest<T>(this IBuilder builder, PathString path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpEndpoint(activity => activity.WithPath(path).WithMethod(HttpMethods.Post).WithTargetType<T>(), lineNumber, sourceFile);
}
}

View file

@ -0,0 +1,37 @@
using System;
using System.Threading.Tasks;
using Elsa.Builders;
using Elsa.Services.Models;
using Microsoft.AspNetCore.Http;
// ReSharper disable once CheckNamespace
namespace Elsa.Activities.Http
{
public static class HttpEndpointExtensions
{
public static ISetupActivity<HttpEndpoint> WithPath(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, ValueTask<PathString>> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpEndpoint> WithPath(this ISetupActivity<HttpEndpoint> activity, Func<ValueTask<PathString>> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpEndpoint> WithPath(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, PathString> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpEndpoint> WithPath(this ISetupActivity<HttpEndpoint> activity, Func<PathString> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpEndpoint> WithPath(this ISetupActivity<HttpEndpoint> activity, PathString path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpEndpoint> WithMethod(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, ValueTask<string?>> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpEndpoint> WithMethod(this ISetupActivity<HttpEndpoint> activity, Func<ValueTask<string?>> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpEndpoint> WithMethod(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, string?> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpEndpoint> WithMethod(this ISetupActivity<HttpEndpoint> activity, Func<string?> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpEndpoint> WithMethod(this ISetupActivity<HttpEndpoint> activity, string? method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpEndpoint> WithReadContent(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, ValueTask<bool>> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpEndpoint> WithReadContent(this ISetupActivity<HttpEndpoint> activity, Func<ValueTask<bool>> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpEndpoint> WithReadContent(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, bool> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpEndpoint> WithReadContent(this ISetupActivity<HttpEndpoint> activity, Func<bool> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpEndpoint> WithReadContent(this ISetupActivity<HttpEndpoint> activity, bool value = true) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpEndpoint> WithTargetType(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, ValueTask<Type?>> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpEndpoint> WithTargetType(this ISetupActivity<HttpEndpoint> activity, Func<ValueTask<Type?>> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpEndpoint> WithTargetType(this ISetupActivity<HttpEndpoint> activity, Func<ActivityExecutionContext, Type?> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpEndpoint> WithTargetType(this ISetupActivity<HttpEndpoint> activity, Func<Type?> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpEndpoint> WithTargetType(this ISetupActivity<HttpEndpoint> activity, Type? value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpEndpoint> WithTargetType<T>(this ISetupActivity<HttpEndpoint> activity) => activity.Set(x => x.TargetType, typeof(T)).WithReadContent();
}
}

View file

@ -1,41 +0,0 @@
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Elsa.Builders;
using Elsa.Services.Models;
using Microsoft.AspNetCore.Http;
// ReSharper disable ExplicitCallerInfoArgument
// ReSharper disable once CheckNamespace
namespace Elsa.Activities.Http
{
public static class HttpRequestReceivedBuilderExtensions
{
public static IActivityBuilder HttpRequestReceived(this IBuilder builder, Action<ISetupActivity<HttpRequestReceived>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.Then(setup, null, lineNumber, sourceFile);
public static IActivityBuilder HttpRequestReceived(this IBuilder builder, Func<ActivityExecutionContext, ValueTask<PathString>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpRequestReceived(this IBuilder builder, Func<ActivityExecutionContext, PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpRequestReceived(this IBuilder builder, Func<ValueTask<PathString>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpRequestReceived(this IBuilder builder, Func<PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder HttpRequestReceived(this IBuilder builder, PathString path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(setup => setup.Set(x => x.Path, path), lineNumber, sourceFile);
public static IActivityBuilder ReceiveHttpPostRequest<T>(this IBuilder builder, Func<ActivityExecutionContext, PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(activity => activity.WithPath(path).WithMethod(HttpMethods.Post).WithTargetType<T>(), lineNumber, sourceFile);
public static IActivityBuilder ReceiveHttpPostRequest<T>(this IBuilder builder, Func<PathString> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(activity => activity.WithPath(path).WithMethod(HttpMethods.Post).WithTargetType<T>(), lineNumber, sourceFile);
public static IActivityBuilder ReceiveHttpPostRequest<T>(this IBuilder builder, PathString path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
builder.HttpRequestReceived(activity => activity.WithPath(path).WithMethod(HttpMethods.Post).WithTargetType<T>(), lineNumber, sourceFile);
}
}

View file

@ -1,37 +0,0 @@
using System;
using System.Threading.Tasks;
using Elsa.Builders;
using Elsa.Services.Models;
using Microsoft.AspNetCore.Http;
// ReSharper disable once CheckNamespace
namespace Elsa.Activities.Http
{
public static class HttpRequestReceivedExtensions
{
public static ISetupActivity<HttpRequestReceived> WithPath(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, ValueTask<PathString>> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpRequestReceived> WithPath(this ISetupActivity<HttpRequestReceived> activity, Func<ValueTask<PathString>> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpRequestReceived> WithPath(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, PathString> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpRequestReceived> WithPath(this ISetupActivity<HttpRequestReceived> activity, Func<PathString> path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpRequestReceived> WithPath(this ISetupActivity<HttpRequestReceived> activity, PathString path) => activity.Set(x => x.Path, path);
public static ISetupActivity<HttpRequestReceived> WithMethod(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, ValueTask<string?>> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpRequestReceived> WithMethod(this ISetupActivity<HttpRequestReceived> activity, Func<ValueTask<string?>> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpRequestReceived> WithMethod(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, string?> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpRequestReceived> WithMethod(this ISetupActivity<HttpRequestReceived> activity, Func<string?> method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpRequestReceived> WithMethod(this ISetupActivity<HttpRequestReceived> activity, string? method) => activity.Set(x => x.Method, method);
public static ISetupActivity<HttpRequestReceived> WithReadContent(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, ValueTask<bool>> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpRequestReceived> WithReadContent(this ISetupActivity<HttpRequestReceived> activity, Func<ValueTask<bool>> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpRequestReceived> WithReadContent(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, bool> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpRequestReceived> WithReadContent(this ISetupActivity<HttpRequestReceived> activity, Func<bool> value) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpRequestReceived> WithReadContent(this ISetupActivity<HttpRequestReceived> activity, bool value = true) => activity.Set(x => x.ReadContent, value);
public static ISetupActivity<HttpRequestReceived> WithTargetType(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, ValueTask<Type?>> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpRequestReceived> WithTargetType(this ISetupActivity<HttpRequestReceived> activity, Func<ValueTask<Type?>> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpRequestReceived> WithTargetType(this ISetupActivity<HttpRequestReceived> activity, Func<ActivityExecutionContext, Type?> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpRequestReceived> WithTargetType(this ISetupActivity<HttpRequestReceived> activity, Func<Type?> value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpRequestReceived> WithTargetType(this ISetupActivity<HttpRequestReceived> activity, Type? value) => activity.Set(x => x.TargetType, value).WithReadContent();
public static ISetupActivity<HttpRequestReceived> WithTargetType<T>(this ISetupActivity<HttpRequestReceived> activity) => activity.Set(x => x.TargetType, typeof(T)).WithReadContent();
}
}

View file

@ -13,9 +13,9 @@ namespace Elsa.Activities.Http.Bookmarks
public string? CorrelationId { get; set; }
}
public class HttpRequestReceivedTriggerProvider : BookmarkProvider<HttpRequestReceivedBookmark, HttpRequestReceived>
public class HttpRequestReceivedTriggerProvider : BookmarkProvider<HttpRequestReceivedBookmark, HttpEndpoint>
{
public override async ValueTask<IEnumerable<IBookmark>> GetBookmarksAsync(BookmarkProviderContext<HttpRequestReceived> context, CancellationToken cancellationToken)
public override async ValueTask<IEnumerable<IBookmark>> GetBookmarksAsync(BookmarkProviderContext<HttpEndpoint> context, CancellationToken cancellationToken)
{
var path = ToLower(await context.Activity.GetPropertyValueAsync(x => x.Path, cancellationToken));
var method = ToLower(await context.Activity.GetPropertyValueAsync(x => x.Method, cancellationToken));

View file

@ -53,7 +53,7 @@ namespace Microsoft.Extensions.DependencyInjection
private static ElsaOptions AddHttpActivitiesInternal(this ElsaOptions options) =>
options
.AddActivity<HttpRequestReceived>()
.AddActivity<HttpEndpoint>()
.AddActivity<WriteHttpResponse>()
.AddActivity<SendHttpRequest>()
.AddActivity<Redirect>();

View file

@ -79,7 +79,7 @@ namespace Elsa.Activities.Http.Middleware
};
var triggers = new[] { triggerWithMethod, triggerWithoutMethod };
var results = await bookmarkFinder.FindBookmarksAsync<HttpRequestReceived>(triggers, TenantId, cancellationToken).ToList();
var results = await bookmarkFinder.FindBookmarksAsync<HttpEndpoint>(triggers, TenantId, cancellationToken).ToList();
if (!results.Any())
{
@ -139,7 +139,7 @@ namespace Elsa.Activities.Http.Middleware
var httpWorkflows =
from workflow in workflows
where workflow.TenantId == TenantId
from activity in workflow.GetStartActivities<HttpRequestReceived>()
from activity in workflow.GetStartActivities<HttpEndpoint>()
select (workflow, activity);
var matches = new List<(IWorkflowBlueprint, IActivityBlueprint, PathString, string?)>();
@ -149,7 +149,7 @@ namespace Elsa.Activities.Http.Middleware
var workflow = httpWorkflow.workflow;
var activity = httpWorkflow.activity;
var workflowWrapper = await workflowBlueprintReflector.ReflectAsync(serviceProvider, workflow, cancellationToken);
var activityWrapper = workflowWrapper.GetActivity<HttpRequestReceived>(activity.Id)!;
var activityWrapper = workflowWrapper.GetActivity<HttpEndpoint>(activity.Id)!;
var path = await activityWrapper.GetPropertyValueAsync(x => x.Path, cancellationToken);
var method = await activityWrapper.GetPropertyValueAsync(x => x.Method, cancellationToken);

View file

@ -18,7 +18,7 @@ namespace Elsa.Samples.CorrelationHttp.Workflows
{
builder
// Configure a Receive HTTP Request trigger that executes on incoming HTTP POST requests.
.HttpRequestReceived(activity => activity.WithPath("/register").WithMethod(HttpMethods.Post).WithTargetType<Registration>())
.HttpEndpoint(activity => activity.WithPath("/register").WithMethod(HttpMethods.Post).WithTargetType<Registration>())
// Store the registration as a workflow variable for easier access.
.SetVariable(context => (Registration)((HttpRequestModel)(context.Input))?.Body)
@ -38,7 +38,7 @@ namespace Elsa.Samples.CorrelationHttp.Workflows
// Configure another Receive HTTP Request trigger that executes on incoming HTTP GET requests.
// This will cause the workflow to become suspended and executed once the request comes in.
.HttpRequestReceived(activity => activity.WithPath("/confirm"))
.HttpEndpoint(activity => activity.WithPath("/confirm"))
// Write an HTTP response with a thank-you note.
// Notice that the correct workflow instance is resumed base on the incoming correlation ID.

View file

@ -12,7 +12,7 @@ namespace Elsa.Samples.CustomActivities
public void Build(IWorkflowBuilder builder)
{
builder
.HttpRequestReceived("/test")
.HttpEndpoint("/test")
.Then<ReadQueryString>()
.WriteHttpResponse(_ => HttpStatusCode.OK, GenerateSomeHtml, _ => "text/html");
}

View file

@ -12,7 +12,7 @@ namespace Elsa.Samples.HelloWorldHttp
public void Build(IWorkflowBuilder builder)
{
builder
.HttpRequestReceived("/hello")
.HttpEndpoint("/hello")
.WriteHttpResponse(HttpStatusCode.OK, "Hello World!", "text/html");
}
}

View file

@ -22,7 +22,7 @@ namespace Elsa.Samples.ReadModelHttp.Workflows
builder
// Configure a Receive HTTP Request trigger that executes on incoming HTTP POST requests.
.HttpRequestReceived(activity => activity.WithPath("/contacts").WithMethod(HttpMethods.Post).WithTargetType<Contact>()).WithName("HttpRequest")
.HttpEndpoint(activity => activity.WithPath("/contacts").WithMethod(HttpMethods.Post).WithTargetType<Contact>()).WithName("HttpRequest")
// Write something to the console to demonstrate that we can receive the outcome of the previous activity (HttpRequest) as an input to this WriteLine activity.
.WriteLine(context => $"Received some contact details: {JsonConvert.SerializeObject(context.Input)}")

View file

@ -12,7 +12,7 @@ namespace ElsaDashboard.Samples.Monolith.Workflows
{
builder
.WithDisplayName("Faulty Workflow")
.HttpRequestReceived("/faulty")
.HttpEndpoint("/faulty")
.Then(ThrowErrorIfFirstRun)
.WriteLine("Made it!");
}

View file

@ -10,7 +10,7 @@ namespace ElsaDashboard.Samples.Monolith.Workflows
{
builder
.WithDisplayName("Goodbye cruel World!")
.HttpRequestReceived("/goodbye-world")
.HttpEndpoint("/goodbye-world")
.WriteHttpResponse(HttpStatusCode.OK, "Goodbye Cruel World!", "text/plain");
}
}

View file

@ -12,7 +12,7 @@ namespace ElsaDashboard.Samples.Monolith.Workflows
.WithWorkflowDefinitionId("HelloWorld")
.WithVersion(1)
.WithDisplayName("Hello World!")
.HttpRequestReceived("/hello-world")
.HttpEndpoint("/hello-world")
.WriteHttpResponse(HttpStatusCode.OK, "Hello World!", "text/plain");
}
}

View file

@ -12,7 +12,7 @@ namespace ElsaDashboard.Samples.Monolith.Workflows
.WithWorkflowDefinitionId("HelloWorld")
.WithVersion(2)
.WithDisplayName("Hello World!")
.HttpRequestReceived("/hello-world/v2")
.HttpEndpoint("/hello-world/v2")
.WriteHttpResponse(HttpStatusCode.OK, "Hello World V2!", "text/plain");
}
}

View file

@ -15,10 +15,10 @@ namespace ElsaDashboard.Samples.Monolith.Workflows
{
builder
.WithDisplayName("Onboarding")
.HttpRequestReceived("/signup")
.HttpEndpoint("/signup")
.Correlate(() => Guid.NewGuid().ToString("N"))
.WriteHttpResponse(x => x.WithStatusCode(HttpStatusCode.OK).WithContent(context => $"Tell me your name please. Use correlation ID {context.WorkflowExecutionContext.CorrelationId}").WithContentType("text/plain"))
.HttpRequestReceived(x => x.WithPath("/signup").WithMethod(HttpMethod.Post.ToString()).WithReadContent())
.HttpEndpoint(x => x.WithPath("/signup").WithMethod(HttpMethod.Post.ToString()).WithReadContent())
.SetVariable("Name", context => (string?) context.GetInput<HttpRequestModel>()!.Body)
.SetName(context => context.GetVariable<string>("Name"))

View file

@ -23,7 +23,7 @@ namespace Elsa.Samples.Server.Host.Workflows
public void Build(IWorkflowBuilder builder)
{
builder
.HttpRequestReceived("/faulty")
.HttpEndpoint("/faulty")
.Then(MaybeThrow)
.WriteHttpResponse(response => response.WithStatusCode(HttpStatusCode.OK).WithContentType("application/json").WithContent(WriteWorkflowInfoAsync));
}

View file

@ -10,7 +10,7 @@ namespace Elsa.Samples.Server.Host.Workflows
{
builder
.WithDisplayName("Goodbye cruel World!")
.HttpRequestReceived("/goodbye-world")
.HttpEndpoint("/goodbye-world")
.WriteHttpResponse(HttpStatusCode.OK, "Goodbye Cruel World!", "text/plain");
}
}

View file

@ -12,7 +12,7 @@ namespace Elsa.Samples.Server.Host.Workflows
.WithWorkflowDefinitionId("HelloWorld")
.WithVersion(1)
.WithDisplayName("Hello World!")
.HttpRequestReceived("/hello-world")
.HttpEndpoint("/hello-world")
.WriteHttpResponse(HttpStatusCode.OK, "Hello World!", "text/plain");
}
}

View file

@ -12,7 +12,7 @@ namespace Elsa.Samples.Server.Host.Workflows
.WithWorkflowDefinitionId("HelloWorld")
.WithVersion(2)
.WithDisplayName("Hello World!")
.HttpRequestReceived("/hello-world/v2")
.HttpEndpoint("/hello-world/v2")
.WriteHttpResponse(HttpStatusCode.OK, "Hello World V2!", "text/plain");
}
}

View file

@ -15,10 +15,10 @@ namespace Elsa.Samples.Server.Host.Workflows
{
builder
.WithDisplayName("Onboarding")
.HttpRequestReceived("/signup")
.HttpEndpoint("/signup")
.Correlate(() => Guid.NewGuid().ToString("N"))
.WriteHttpResponse(x => x.WithStatusCode(HttpStatusCode.OK).WithContent(context => $"Tell me your name please. Use correlation ID {context.WorkflowExecutionContext.CorrelationId}").WithContentType("text/plain"))
.HttpRequestReceived(x => x.WithPath("/signup").WithMethod(HttpMethod.Post.ToString()).WithReadContent())
.HttpEndpoint(x => x.WithPath("/signup").WithMethod(HttpMethod.Post.ToString()).WithReadContent())
.SetVariable("Name", context => (string) context.GetInput<HttpRequestModel>().Body)
.SetName(context => context.GetVariable<string>("Name"))