示例#1
0
        public static IServiceCollection AddElsaApiEndpoints(this IServiceCollection services, Action <ElsaApiOptions>?configureApiOptions = default)
        {
            var apiOptions = new ElsaApiOptions();

            configureApiOptions?.Invoke(apiOptions);

            var setupNewtonsoftJson = apiOptions.SetupNewtonsoftJson ?? (_ => { });

            services.AddControllers().AddNewtonsoftJson(setupNewtonsoftJson);
            services.AddRouting(options => { options.LowercaseUrls = true; });

            services.AddVersionedApiExplorer(o =>
            {
                o.GroupNameFormat           = "'v'VVV";
                o.SubstituteApiVersionInUrl = true;
            });

            services.AddApiVersioning(
                options =>
            {
                options.ReportApiVersions = true;
                options.DefaultApiVersion = ApiVersion.Default;
                options.AssumeDefaultVersionWhenUnspecified = true;
            });

            services
            .AddSingleton <ConnectionConverter>()
            .AddSingleton <ActivityBlueprintConverter>()
            .AddScoped <IWorkflowBlueprintMapper, WorkflowBlueprintMapper>()
            .AddSingleton <IEndpointContentSerializerSettingsProvider, EndpointContentSerializerSettingsProvider>()
            .AddAutoMapperProfile <AutoMapperProfile>()
            .AddSignalR();

            return(services);
        }
 public static IServiceCollection AddElsaApiEndpoints(this IServiceCollection services, ElsaApiOptions apiOptions) =>
 services.AddElsaApiEndpoints(options =>
 {
     options.SetupNewtonsoftJson = apiOptions.SetupNewtonsoftJson;
 });