Releases: giraffe-fsharp/Giraffe
3.1.0
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
Breaking changes
-
Changed the type
XmlNode
by removing theRawText
andEncodedText
union case and replaced both by a singleText
union case. The HTML encoding (or not) is being done now when calling one of the two helper functionsrawText
andencodedText
.- 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 typeRawText
orEncodedText
(which is extremely unlikely given that there's not much room for more nodes of these two types).
- This change - even though theoretically a breaking change - should not affect the vast majority of Giraffe users unless you were constructing your own
-
Removed the
task {}
override in Giraffe which was forcing theFSharp.Control.Tasks.V2.ContextInsensitive
version of the Task CE. This change has no effect on the behaviour oftask
computation expressions in Giraffe. In the context of an ASP.NET Core web application there is not difference betweenContextSensitive
andContextInsensitive
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 explicitlyopen FSharp.Control.Tasks.V2.ContextInsensitive
where before it might have been sufficient to onlyopen 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 aStringBuilder
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), butUtf8JsonSerializer
can be swapped in via ASP.NET Core's dependency injection API. The newUtf8JsonnSerializer
is significantly faster (especially when sending chunked responses) thanNewtonsoftJsonSerializer
. - Added a new
HttpContext
extension method for chunked JSON transfers:WriteJsonChunkedAsync<'T> (dataObj : 'T)
. This newHttpContext
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 theWriteJsonChunkedAsync
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
Changed the task {}
CE to load from FSharp.Control.Tasks.V2.ContextInsensitive
instead of FSharp.Control.Tasks.ContextInsensitive
.
2.0.0
Breaking changes
- Changed the name of the handler
requiresAuthPolicy
toevaluateUserPolicy
in order to better describe its functionality and to avoid a name clash between two newly added handlers for validating ASP.NET Core'sAuthorizationPolicy
objects (see new features). - Changed how he
AddGiraffe()
extension method registers Giraffe dependencies in ASP.NET Core. It now follows theTryAdd
pattern which will only register a dependency if it hasn't been registered beforehand. - Changed the
HttpContext.GetService<'T>()
extension method to throw aMissingDependencyException
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). TheauthorizeByPolicyName
andauthorizeByPolicy
http handlers will use ASP.NET Core's authorization service to validate a user against a given policy. - Updated
TaskBuilder.fs
to version2.0.*
. - Updated ASP.NET Core NuGet packages to latest
2.1.*
versions. - Enabled
return!
foropt { }
computation expressions. - Added
blockquote
,_integrity
and_scoped
to theGiraffeViewEngine
. - 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 theGiraffe.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
andsubRoutef
which prohibited to parse multiple GUIDs - Fixed a bug in
routef
,routeCif
andsubRoutef
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 thebindModel<'T>
http handler to also bind to a model in the case of aPATCH
orDELETE
http request.
1.2.0-preview-1
- Updated
TaskBuilder.fs
dependency to version1.2.0-rc
. - Fixed bug in
routef
,routeCif
andsubRoutef
to parse multiple guids
1.1.0
New features
- Added
subRoutef
http handler (see subRoutef) - Added
routex
androuteCix
http handler (see routex) - Improved model binding (see Model Binding)
- Added new Model Validation API
Bug fixes
routeBind
works when nested in asubRoute
handler nowrouteBind
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
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 andHttpHandler
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
anddeserializeXml<'T>
- Removed
- Removed the
customJson
http handler - Renamed the
html
http handler tohtmlString
- Renamed the
renderHtml
http handler tohtmlView
- Renamed
setBodyAsString
http handler tosetBodyFromString
- Renamed
ReturnHtmlFileAsync()
toWriteHtmlFileAsync()
- The function can also accept relative and absolute file paths now
- Renamed
RenderHtmlAsync()
toWriteHtmlViewAsync()
- Removed the overloads for
BindJsonAsync<'T>
,BindModelAsync<'T>
andWriteJsonAsync
which accepted an object of typeJsonSerializerSettings
- Renamed the
signOff
http handler tosignOut
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
Breaking changes
- Renamed
portRoute
toroutePorts
to be more consistent with other routing functions (route
,routef
,routeStartsWith
, etc.)
New features
routef
androuteCif
both support%O
for matchingSystem.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
Breaking changes
- Renamed
Giraffe.XmlViewEngine
toGiraffe.GiraffeViewEngine
as it represented more than just an XML view engine.
New features
- Added automatic validation of the format string inside
routef
androuteCif
to notify users of the notorious%d
vs%i
error during startup.
0.1.0-beta-511
Bug fixes
- Fixed
ReadBodyFromRequestAsync
where the stream has been disposed before read could complete.