Skip to content

Releases: giraffe-fsharp/Giraffe

3.1.0

28 Sep 19:57
Compare
Choose a tag to compare

New features

  • Added a new http handler called validatePreconditions to help with conditional requests:

    let someHandler (eTag : string) (content : string) =
        let eTagHeader = Some (EntityTagHeaderValue.FromString true eTag)
        validatePreconditions eTagHeader None
        >=> setBodyFromString content
  • Made previously internal functionality for sub routing available through the SubRouting module:

    • SubRouting.getSavedPartialPath: Returns the currently partially resolved path.
    • SubRouting.getNextPartOfPath: Returns the yet unresolved part of the path.
    • SubRouting.routeWithPartialPath: Invokes a route handler as part of a sub route.

Improvements

  • Performance improvements for Giraffe's default response writers.
  • Performance improvements of the htmlView handler.
  • Upgraded to the latest TaskBuilder.fs NuGet package which also has the SourceLink integration now.

Bug fixes

  • Fixed the Successful.NO_CONTENT http handler, which threw an exception when calling from ASP.NET Core 2.1.

3.0.0

18 Sep 06:58
Compare
Choose a tag to compare

Breaking changes

  • Changed the type XmlNode by removing the RawText and EncodedText union case and replaced both by a single Text union case. The HTML encoding (or not) is being done now when calling one of the two helper functions rawText and encodedText.

    • This change - even though theoretically a breaking change - should not affect the vast majority of Giraffe users unless you were constructing your own XmlNode elements which were of type RawText or EncodedText (which is extremely unlikely given that there's not much room for more nodes of these two types).
  • Removed the task {} override in Giraffe which was forcing the FSharp.Control.Tasks.V2.ContextInsensitive version of the Task CE. This change has no effect on the behaviour of task computation expressions in Giraffe. In the context of an ASP.NET Core web application there is not difference between ContextSensitive and ContextInsensitive which is why the override has been removed. The only breaking change which could affect an existing Giraffe web application is that in some places you will need to explicitly open FSharp.Control.Tasks.V2.ContextInsensitive where before it might have been sufficient to only open Giraffe.

  • Changed the members of the IJsonSerializer interface to accommodate new (de-)serialize methods for chunked encoding transfer.

    The new interface is the following:

    type IJsonSerializer =
        abstract member SerializeToString<'T>      : 'T -> string
        abstract member SerializeToBytes<'T>       : 'T -> byte array
        abstract member SerializeToStreamAsync<'T> : 'T -> Stream -> Task
    
        abstract member Deserialize<'T>      : string -> 'T
        abstract member Deserialize<'T>      : byte[] -> 'T
        abstract member DeserializeAsync<'T> : Stream -> Task<'T>

Improvements

  • Significant performance improvements in the GiraffeViewEngine by changing the underlying composition of views from simple string concatenation to using a StringBuilder object.

New features

  • Support for short GUIDs and short IDs (aka YouTube IDs) in route arguments and query string parameters.
  • Enabled SourceLink support for Giraffe source code (thanks Cameron Taggart)! For more information check out Adding SourceLink to your .NET Core Library.
  • Added a new JSON serializer called Utf8JsonSerializer. This type uses the Utf8 JSON serializer library, which is currently the fastest JSON serializer for .NET. NewtonsoftJsonSerializer is still the default JSON serializer in Giraffe (for stability and backwards compatibility), but Utf8JsonSerializer can be swapped in via ASP.NET Core's dependency injection API. The new Utf8JsonnSerializer is significantly faster (especially when sending chunked responses) than NewtonsoftJsonSerializer.
  • Added a new HttpContext extension method for chunked JSON transfers: WriteJsonChunkedAsync<'T> (dataObj : 'T). This new HttpContext method can write content directly to the HTTP response stream without buffering into a byte array first (see Writing JSON).
  • Added a new jsonChunked http handler. This handler is the equivalent http handler version of the WriteJsonChunkedAsync extension method.
  • Added first class support for ASP.NET Core's response caching feature.

Special thanks

Special thanks to Dmitry Kushnir for doing the bulk work of all the perf improvements in this release as well as adding Giraffe to the TechEmpower Webframework Benchmarks!

2.0.1

20 Aug 19:11
Compare
Choose a tag to compare

Changed the task {} CE to load from FSharp.Control.Tasks.V2.ContextInsensitive instead of FSharp.Control.Tasks.ContextInsensitive.

2.0.0

18 Aug 22:46
Compare
Choose a tag to compare

Breaking changes

  • Changed the name of the handler requiresAuthPolicy to evaluateUserPolicy in order to better describe its functionality and to avoid a name clash between two newly added handlers for validating ASP.NET Core's AuthorizationPolicy objects (see new features).
  • Changed how he AddGiraffe() extension method registers Giraffe dependencies in ASP.NET Core. It now follows the TryAdd pattern which will only register a dependency if it hasn't been registered beforehand.
  • Changed the HttpContext.GetService<'T>() extension method to throw a MissingDependencyException if it cannot resolve a desired dependency.

New features

  • Added two new http handlers to validate an ASP.NET Core AuthorizationPolicy (see: Policy based authorization). The authorizeByPolicyName and authorizeByPolicy http handlers will use ASP.NET Core's authorization service to validate a user against a given policy.
  • Updated TaskBuilder.fs to version 2.0.*.
  • Updated ASP.NET Core NuGet packages to latest 2.1.* versions.
  • Enabled return! for opt { } computation expressions.
  • Added blockquote, _integrity and _scoped to the GiraffeViewEngine.
  • Added attributes for mouse, keyboard, touch, drag & drop, focus, input and mouse wheel events to the GiraffeViewEngine.
  • Added new accessibility attributes to the GriaffeViewEngine. These can be used after opening the Giraffe.GiraffeViewEngine.Accessibility module.
  • Added a new Successful.NO_CONTENT http handler which can be used to return a HTTP 204 response.
  • Added more structured logging around the Giraffe middleware.

Bug fixes

  • Fixed a bug in routef, routeCif and subRoutef which prohibited to parse multiple GUIDs
  • Fixed a bug in routef, routeCif and subRoutef which wrongly decoded a route argument twice (and therefore turned + signs into spaces).
  • Fixed XML documentation for all Giraffe functions which should make function tooltips nicely formatted again.
  • Enabled the HttpContext.BindModelAsync<'T>() extension method and the bindModel<'T> http handler to also bind to a model in the case of a PATCH or DELETE http request.

1.2.0-preview-1

06 Mar 05:46
Compare
Choose a tag to compare
1.2.0-preview-1 Pre-release
Pre-release
  • Updated TaskBuilder.fs dependency to version 1.2.0-rc.
  • Fixed bug in routef, routeCif and subRoutef to parse multiple guids

1.1.0

16 Feb 13:19
Compare
Choose a tag to compare

New features

  • Added subRoutef http handler (see subRoutef)
  • Added routex and routeCix http handler (see routex)
  • Improved model binding (see Model Binding)
    • Fixed issues: #121, #206
    • Added a TryBindFormAsync and a TryBindQueryString HttpContext extension methods
    • Added new HttpHandler functions to offer a more functional API for model binding:
      • bindJson<'T>
      • bindXml<'T>
      • bindForm<'T>
      • tryBindForm<'T>
      • bindQuery<'T>
      • tryBindQuery<'T>
      • bindModel<'T>
  • Added new Model Validation API

Bug fixes

  • routeBind works when nested in a subRoute handler now
  • routeBind doesn't crate a model object any more if the route arguments do not match the provided model

To see an example of the new features you can check the official Giraffe 1.1.0 release blog post.

1.0.0

08 Feb 23:51
Compare
Choose a tag to compare

1.0.0

First RTM release of Giraffe.

This release has many minor breaking changes and a few bigger features. Please read the changelog carefully before updating your existing application.

New features

  • JSON and XML serialization is now configurable through Dependency Injection (see Serialization)
  • Added new features to validate conditional HTTP headers before processing a web request (see Conditional Requests)
  • Added streaming capabilities (see Streaming)
  • Added HEAD, OPTIONS, TRACE, CONNECT http handlers
  • Added more HttpContext extension methods to create parity between response writing methods and HttpHandler functions (see Response Writing and Content Negotiation)
  • Added detailed XML docs to all public facing functions for better Intellisense support
  • The Giraffe.Common module auto opens now

Breaking changes

  • Deprecated Griaffe.Tasks. Giraffe uses the original TaskBuilder.fs library now.
  • Giraffe comes with a default set of required dependencies which need to be registered via services.AddGiraffe() during application startup now
  • The Giraffe.TokenRouter library has been moved to a separate NuGet package under the same name
  • Removed redundant serialization methods
    • Removed serializeJson, deserializeJson<'T>, deserializeJsonFromStream<'T>, defaultJsonSerializerSettings, defaultSerializeJson, defaultDeserializeJson<'T>, serializeXml and deserializeXml<'T>
  • Removed the customJson http handler
  • Renamed the html http handler to htmlString
  • Renamed the renderHtml http handler to htmlView
  • Renamed setBodyAsString http handler to setBodyFromString
  • Renamed ReturnHtmlFileAsync() to WriteHtmlFileAsync()
    • The function can also accept relative and absolute file paths now
  • Renamed RenderHtmlAsync() to WriteHtmlViewAsync()
  • Removed the overloads for BindJsonAsync<'T>, BindModelAsync<'T> and WriteJsonAsync which accepted an object of type JsonSerializerSettings
  • Renamed the signOff http handler to signOut to be more consistent with existing ASP.NET Core naming conventions

To get a summary of the new features and changes you can check the official Giraffe 1.0.0 release blog post.

0.1.0-beta-700

22 Dec 11:57
Compare
Choose a tag to compare
0.1.0-beta-700 Pre-release
Pre-release

Breaking changes

  • Renamed portRoute to routePorts to be more consistent with other routing functions (route, routef, routeStartsWith, etc.)

New features

  • routef and routeCif both support %O for matching System.Guid values now
  • Added HTML attributes helper functions to the GiraffeViewEngine.

Example:

let html = p [ _class "someCssClass"; _id "greetingsText" ] [ encodedText "Hello World" ]

0.1.0-beta-600

20 Dec 15:11
Compare
Choose a tag to compare
0.1.0-beta-600 Pre-release
Pre-release

Breaking changes

  • Renamed Giraffe.XmlViewEngine to Giraffe.GiraffeViewEngine as it represented more than just an XML view engine.

New features

  • Added automatic validation of the format string inside routef and routeCif to notify users of the notorious %d vs %i error during startup.

0.1.0-beta-511

19 Dec 19:18
Compare
Choose a tag to compare
0.1.0-beta-511 Pre-release
Pre-release

Bug fixes

  • Fixed ReadBodyFromRequestAsync where the stream has been disposed before read could complete.