Skip to content

use* items are applied to ApplicationBuilder in reverse order. #392

@deapsquatter

Description

@deapsquatter

In Application.fs new items are prepended as follows:

config::state.AppConfigs

The AppConfigs list is then copied in the same order to a ResizeArray:

// as we want to add middleware to our pipeline, we can add it here and we'll fold across it in the end
let useParts = ResizeArray<IApplicationBuilder -> IApplicationBuilder>()

// user-provided middleware
state.AppConfigs |> List.iter (useParts.Add)

Finally we fold over the ResizeArray in the same order:

let wbhst =
  wbhst.Configure(fun ab ->
    (ab, useParts)
    ||> Seq.fold (fun ab part -> part ab)
    |> ignore
  )

This breaks middleware that depends on a logical order as added in the application computation expression.

In this example static content does not get redirected to SSL even thought thats what a user would expect:

let app = application {
force_ssl
use_static
}

The use_static has to be before the force_ssl to work correctly because of this bug (not intuitive)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions