- Removed redundant dependencies
- Fixed model binding for arrays (see #403)
- Fixed pre-condition bug for the
If-Unmodified-Since
HTTP header (see #402) - Added
netcoreapp3.1
support
Fixed dependency references for TFM netcoreapp3.0
projects.
Giraffe 4.0.0 has been tested against netcoreapp3.0
alongside netcoreapp2.1
and net461
. All sample code has been upgraded to .NET Core 3.0 as well.
This release of Giraffe fixes a bug in the routef
handler which would have previously matched a route too eagerly.
Route: /foo/bar/hello/world
routef: /foo/bar/%s
Match: true
Route: /foo/bar/hello/world
routef: /foo/bar/%s
Match: false
For more information please see issue #347.
- Support array of 'T as a child in form binding
- Added a new
DateTime
extension methodToIsoString
which produces a RFC3339 formatted string, and corrected the docs on the existingToHtmlString
extension method which actually produces a RFC822 formatted string.
-
Fixed
routef
to not match more than one URL path segment. -
Fixed the
_ariaLabelledBy
attribute in theGiraffeViewEngine
-
Fixed case insensitive route handlers on Ubuntu
-
Changed minimum version of
Newtonsoft.Json
to11.0.2
. This allows Giraffe to be compatible with Azure Functions. -
Renamed
tryMatchInput
totryMatchInputExact
and swapped the order of arguments so that the string value comes last -
Added new version of
tryMatchInput
which acceptsMatchSettings
record:type MatchMode = | Exact // Will try to match entire string from start to end. | StartsWith // Will try to match a substring. Subject string should start with test case. | EndsWith // Will try to match a substring. Subject string should end with test case. | Contains // Will try to match a substring. Subject string should contain test case. type MatchOptions = { IgnoreCase: bool; MatchMode: MatchMode; }
- Fixed a bug in the
subRouteCi
http handler, which prevented nested sub routes to be case insensitive.
- Added two new
HttpContext
extension methods to retrieve cookie and form values:GetCookieValue (key : string)
GetFormValue (key : string)
- Fixed a bug in Giraffe's model binding to not try to set read only properties anymore.
- Updated all packages and framework library dependencies to .NET Core 2.2.
- Added a new
GET_HEAD
http handler (see: #314 for more info). - Added a new convenience function called
handleContext
, which can be used for creating newHttpHandler
functions.
- Fixed the
_data
attribute in theGiraffeViewEngine
to accept akey
andvalue
parameter now.
- Added a new http handler called
authorizeRequest
to authorize a request based on aHttpContext -> bool
predicate. - Added a new http handler called
authorizeUser
which is an alias forevaluateUserPolicy
. TheevaluateUserPolicy
handler will be removed in the next major release.
- Added
str
as an alias for theencodedText
function from theGiraffeViewEngine
. - Added the
HttpContext.GetRequestUrl()
extension method to retrieve the entire URL string of the incoming HTTP request.
- Adding the
charset
parameter in the HTTPContent-Type
response header when returning a text response (text/plain, text/html) or a JSON or XML response (application/json, application/xml). By default Giraffe is using UTF8 encoding for all its responses.
-
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.
- 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.
- Fixed the
Successful.NO_CONTENT
http handler, which threw an exception when calling from ASP.NET Core 2.1.
-
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>
- Significant performance improvements in the
GiraffeViewEngine
by changing the underlying composition of views from simple string concatenation to using aStringBuilder
object.
- 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 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!
Changed the task {}
CE to load from FSharp.Control.Tasks.V2.ContextInsensitive
instead of FSharp.Control.Tasks.ContextInsensitive
.
- 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.
- 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
GiraffeViewEngine
. 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.
- 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.
- Added
subRoutef
http handler (see subRoutef) - Added
routex
androuteCix
http handler (see routex) - Improved model binding (see Model Binding)
- Added new Model Validation API
To see an example of the new features you can check the official Giraffe 1.1.0 release blog post.
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
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.
- 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
- 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.
- Renamed
portRoute
toroutePorts
to be more consistent with other routing functions (route
,routef
,routeStartsWith
, etc.)
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" ]
- Renamed
Giraffe.XmlViewEngine
toGiraffe.GiraffeViewEngine
as it represented more than just an XML view engine.
- Added automatic validation of the format string inside
routef
androuteCif
to notify users of the notorious%d
vs%i
error during startup.
- Fixed
ReadBodyFromRequestAsync
where the stream has been disposed before read could complete.
- Explicitly set the encoding to UTF-8 when reading the HTTP body during
ReadBodyFromRequestAsync
- Added the
html
http handler which can be used to return atext/html
response by passing in the html content as a string variable
- Added a new overload for
GetLogger
of theHttpContext
extension methods, which allows one to pass in acategoryName
string in order to initialise a new logger:let logger = ctx.GetLogger "categoryName"
. BindFormAsync
,BindQueryString
andBindModelAsync
accept an additional optional parameter forCultureInfo
.
- Removed
Giraffe.Tasks
from theGiraffe
NuGet package and added a new dependency on the newly createdGiraffe.Tasks
NuGet package. You can use theGiraffe.Tasks
NuGet package from non ASP.NET Core projects now as well.
- Added HTTP status code helper functions.
- Added
defaultSerializeJson
anddefaultDeserializeJson
methods. - Auto opened default Giraffe modules so that the core functionality can be entirely consumed through a single
open Giraffe
statement. - The functionality from
Giraffe.Razor.Middleware
andGiraffe.Razor.HttpHandlers
can be both consumed through a singleopen Giraffe.Razor
now.
- Changed the
base
tag from theXmlViewEngine
from a regulartag
to avoidTag
to comply with the HTML spec.
- Renamed all async methods by appending
Async
at the end of the method in order to comply with the general .NET naming conventionreadFileAsString
-->readFileAsStringAsync
ctx.ReadBodyFromRequest
-->ctx.ReadBodyFromRequestAsync
ctx.BindJson
-->ctx.BindJsonAsync
ctx.BindXml
-->ctx.BindXmlAsync
ctx.BindForm
-->ctx.BindFormAsync
ctx.BindModel
-->ctx.BindModelAsync
ctx.WriteJson
-->ctx.WriteJsonAsync
ctx.WriteXml
-->ctx.WriteXmlAsync
ctx.WriteText
-->ctx.WriteTextAsync
ctx.RenderHtml
-->ctx.RenderHtmlAsync
ctx.ReturnHtmlFile
-->ctx.ReturnHtmlFileAsync
- Renamed
Giraffe.DotLiquid.HttpHandlers
module toGiraffe.DotLiquid
- Added
portRoute
http handler to filter an incoming request based on the port
- The
GET
,POST
,PUT
andDELETE
http handlers of theTokenRouter.fs
have changed to accept a list of http handlers now.
- TokenRouter fringe case not being identified before (see #150)
- Added
requiresAuthPolicy
http handler - Added
RenderHtml
andReturnHtmlFile
extension methods to theHttpContext
object - Added
customJson
http handler, which allows users to define a custom json handler (with custom serialization settings) - Added overloads to
BindJson
andBindModel
where a user can pass in a customJsonSerializerSettings
object
- Changed the default json serializer to use camel case for serialization (this change prevents users from being able to change the default serializer through the
JsonConvert.DefaultSettings
object - usecustomJson
instead if customization is required) - Changed the
serializeJson
,deserializeJson
methods to accept an aditional parameter of typeJsonSerializerSettings
- Automatically URL decoding of string values when using
routef
- Fixed an inference bug with
routef
by replacing theformat
parameter of thetryMatchInput
method and thepath
parameter of theroutef
androuteCif
methods fromStringFormat
toPrintFormat
- Changed the implementation of
ctx.BindJson<'T>()
for better performance and which aims to fix an Azure bug with Kestrel (#136) - Fixed a bug with
routeBind
(#129) - Improved the
htmlFile
http handler by allowing thefilePath
parameter to be either rooted or relative to theContentRootPath
- Added three additional
HttpContext
extension methods in theGiraffe.HttpContextExtensions
module:WriteJson
,WriteXml
andWriteText
. These three methods can be used for direct HttpReponse writing from within a custom handler without having to sub-call thejson
,xml
ortext
http handlers. - Changed the
UseGiraffeErrorHandler
method to return anIApplicationBuilder
now. This change allows middleware chaining. This is a breaking change and you'll either have to chain middleware or append an|> ignore
in your application set up.
Added the Giraffe.TokenRouter
module for speed improved route handling.
Improved the routeBind
http handler to give users more flexibility in mapping routes to HTTP requests (see #110).
- Fixed bug in connection with the
ExceptionHandlerMiddleware
(see #106) - Added CORS settings for localhost to the default giraffe-template
Attention, this release updated all Giraffe NuGet packages to net461
and netstandard2.0
!
You will have to upgrade your ASP.NET Core application to either full .NET framework 461 or to a .NET Core app 2.0.
There were a few minor breaking changes in ASP.NET Core 2.0 which also affected Giraffe. I do not intend to keep maintaining a 1.x version any longer unless there's a very compelling reason. General advice is to upgrade all .NET Core web applications to 2.0.
- Fixed bug where
readFileAsString
closed the stream before the file could be read
- Fixed bug so that
_ViewStart.cshtml
files get respected now
- Fixed wrong version numbers in package references for
Giraffe
andGiraffe.Razor
- Fixed the
warbler
function. Should work as expected again. - Added support for
Async<'T>
in thetask {}
workflow. You can use anAsync<'T>
from withintask {}
without having to convert back to aTask<'T>
- Set the Giraffe dependency version in the template to a concrete version to avoid breaking changes in the template.
First Beta release of Giraffe!
The HttpHandler
has slightly changed.
Blog post with more info is coming shortly!
Changed the type XmlAttribute
from the XmlViewEngine
to accept either a string * string
key value pair or a boolean attribute of type string
. This was a missing to enable script tags such as <script src="..." async></script>
.
Added two helper functions (attr
and flag
) to simplify the creation of those attributes:
script [
attr "src" "http://example.org/example.js"
attr "lang" "javascript"
flag "async" ] []
- New
routeBind
http handler - Annotated all default http handler functions with the
HttpHandler
type
- Fixed build error in the Giraffe template.
- Renamed
renderXmlString
torenderXmlNode
and renamedrenderHtmlString
torenderHtmlNode
- Added two more methods which accept a
XmlNode list
:renderXmlNodes
andrenderHtmlNodes
- Changed the return value of
encodedText
andrawText
to return a singleXmlNode
instead ofXmlNode list
. This has the advantage that it can be used from within another list, which was not possible before.
Before:
let view =
html [] [
head [] [
title [] (rawText "Giraffe")
]
body [] (encodedText "Hello World")
]
Now:
let view =
html [] [
head [] [
title [] [ rawText "Giraffe" ]
]
body [] [ encodedText "Hello World" ]
]
This has the advantage that you can also do this, which wasn't possible before:
let view =
html [] [
head [] [
title [] [ rawText "Giraffe" ]
]
body [] [
encodedText "Hello World"
p [] [ rawText "Hello" ]
]
]
A few modifications to the former HtmlEngine
so that it can be used for correct XML rendering as well:
- Renamed the
Giraffe.HtmlEngine
module toGiraffe.XmlViewEngine
- Renamed
HtmlAttribute
toXmlAttribute
,HtmlElement
toXmlElement
andHtmlNode
toXmlNode
- Renamed and make the function
nodeToHtmlString
private - Added
comment
function to theGiraffe.XmlViewEngine
module for creating XML comments - Added
renderXmlString
andrenderHtmlString
functions toGiraffe.XmlViewEngine
module for rendering XML and HTML nodes.
- Changed
HttpContext.BindQueryString<'T>()
to return'T
instead ofAsync<'T>
- Added
HttpContext.TryGetQueryStringValue (key : string)
which returns anOption<string>
- Added
HttpContext.GetQueryStringValue (key : string)
which returns aResult<string, string>
Split out the Razor view engine and the DotLiquid templating engine into separate NuGet packages:
Giraffe.Razor
Giraffe.DotLiquid
Please reference the additional packages if you were using any of the view or templating handlers.
Also updated the giraffe-template
NuGet package with the new changes and adapted the build.ps1
PowerShell script to successfully build on Linux environments too.
Additionally TravisCI builds are run as part of every commit as well now.
Adds support for the Option<'T>
type when model binding from a query string.
- Added two new
HttpContext
extension methods:TryGetRequestHeader (key : string)
which returns anOption<string>
GetRequestHeader (key : string)
which returns aResult<string, string>
- Added default computation expressions for the
Option<'T>
andResult<'T, 'TError>
types underGiraffe.ComputationExpressions
- Added
plain/text
as a new supported mime type to the defaultnegotiate
handler (it will be using an object's.ToString()
method to serialize an object into plain text) - Added new helper functions for retrieving a logger or dependencies as extension methods of the
HttpContext
object:ctx.GetService<'T>()
andctx.GetLogger<'T>()
- Completely removed the
HttpHandlerContext
type and replaced all usage with the originalHttpContext
object from ASP.NET Core. - Extended the
ErrorHandler
function with a parameter to retrieve a defaultILogger
object - Moved model binding functions from the
Giraffe.ModelBinding
module into theGiraffe.HttpContextExtensions
module and made them extension methods of theHttpContext
object
Also updated the giraffe-template
NuGet package with the latest changes.
Fixes #46
Changed the signature of the redirectTo
http handler (swapped permanent
with location
).
Added redirectTo
http handler.
Using culture invariant converters in model binders.
- Added
bindQueryString
which can automatically bind a model from query string parameters - Extended
bindModel
to includebindQueryString
when the HTTP method is notPOST
orPUT
- Added a
warbler
function - Added model binding capabilities which can automatically bind a HTTP payload to a strongly typed model:
bindJson
,bindXml
,bindForm
andbindModel
- Improved the
negotiateWith
andnegotiate
http handlers by making use of ASP.NET Core'sMediaTypeHeaderValue
class - Added
*.cshtml
files to the DotNet watcher in the template
- Fixed
AssemblyName
andPackageId
values in the template
Added two new HttpHandler
functions:
negotiate
checks theAccept
header of a request and determines automatically if a response should be sent in JSON or XMLnegotiateWith
is the same asnegotiate
, but additionally accepts anIDictionary<string, obj -> HttpHandler>
which allows users to extend the default negotiation rules (e.g. change default serialization if a client is indifferent, or add more supported mime types, etc.)
- Added a new programmatic view engine called
Giraffe.HtmlEngine
- Addd a new
HttpHandler
namedrenderHtml
to return views from the new view engine
- Updated
Newtonsoft.Json
to version10.0.*
- Updated the Giraffe
dotnet new
template
- NuGet package is being built with official VS 2017 build image by AppVeyor (using .NET Core SDK 1.0.1)
- Created a NuGet package called
giraffe-template
which is a newdotnet new
template for Giraffe projects - Removed
RazorLight
as a dependency and replaced it with the official razor engine by ASP.NET Core MVC - Renamed the HttpHandler
htmlTemplate
todotLiquidHtmlView
- Added a new HttpHandler named
dotLiquidTemplate
. The difference is that it let's the caller decide whatContent-Type
the response shall be. - Renamed the HttpHandler
razorView
torazorHtmlView
- Added a new HttpHandler named
razorView
. The difference is that it let's the caller decide whatContent-Type
the response shall be.
Attention, this release creates a new NuGet package named Giraffe.nupkg, which will be the new NuGet library for this project going forward.
The old package AspNetCore.Lambda.nupkg will remain as is for backwards compatibility and not be removed or updated anymore.
- Added a default logger to the
HttpHandlerContext
- Renamed NuGet package to Giraffe
- Changed dependency from
Microsoft.AspNetCore.Hosting
toMicrosoft.AspNetCore.Hosting.Abstractions
- Added
razorView
HttpHandler
This version has some breaking changes
- Re-factored
bind
to make it a true bind function - Added a new
compose
combinator - The
>>=
operator became>=>
now and>>=
is the newbind
function (Fixes #5) - Upgraded project to .NET Core SDK RC4
- Upgraded to FSharp.Core 4.1.0
- Added
subRoute
andsubRouteCi
handlers (Fixes #7 ) - Uses culture invariant parse functions for
routef
androuteCif
(See #8)
- Changed the
HttpHandlerContext
to include anIServiceProvider
and removedIHostingEnvironment
andILoggerFactory
instead - Added more default HttpHandlers:
challenge
,signOff
,requiresAuthentication
,requiresRole
,requiresRoleOf
,clearResponse
andxml
- Added XML documentation to all default HttpHandlers
- Updated to latest Microsoft.FSharp.Core.netcore NuGet package, which is in RC now
- Changed the name of the
ErrorHandlerMiddleware
toLambdaErrorHandlerMiddleware
and changed theIApplicationBuilder
extension method toUseLambdaErrorHandler
First alpha release with a basic set of functionality.