- Some security fixes for Giraffe - Credits @Thorium
- New handlers added to improve security aspects, like
safeRedirectTo,safeRedirectToExt,validateCsrfTokenExtand more. Those deal with:- URL validation in
redirectToto prevent cross-site scripting (XSS) - Cross-Site Request Forgery (CSRF) token validation helpers
- URL validation in
- XML serializer's
Deserialize<'T>(xml: string)method now uses a configuration to prevent XXE attacks.
- New handlers added to improve security aspects, like
- Remove [<AllowNullLiteral>] attribute from Json.ISerializer and Xml.ISerializer - Credits @64J0
- With the release of .NET 9 we have nullable reference types.
- When this feature is enabled (
<Nullable>enable</Nullable>), our users started running into problems that boils down toJson.ISerializerhaving theAllowNullLiteralattribute. - Due to it, we decided to remove this attribute from both the
Json.ISerializerand theXml.ISerializer.- New automated tests were added to assert that the serializers are still working properly.
- We also updated some sample projects to use this feature.
- Remove Obsolete from redirectTo - Credits @kerams
- Could we avoid allocation of UTF8 byte array? - Credits @Thorium
- Update fsharp-analyzers and the analyzer packages - Credits @Numpsy
- Improve JSON docs - Credits @64J0
- Add issue templates - Credits @64J0
- Enhance routef support for named parameters and improve documentation - Credits @RJSonnenberg
- Fix assembly version
- Add GitHub dependabot configuration - Credits @64J0
- Add global rate limiting sample - Credits @64J0
- Add OpenApi section to the documentation - Credits @64J0
- Add AssemblyVersion attribute - Credits @64J0
- Add more links - Credits @64J0
- Code scanning fix patches - Credits @64J0
- Add .NET 9 as target framework, fine-tune dependabot, update CI and clean tests removing .NET 6/7 from target frameworks - Credits @64J0
- [Alpha] Add Endpoint routing functions ...WithExtensions - Credits @64J0
- Remove Obsolete from redirectTo - Credits @kerams
- Some security fixes for Giraffe - Credits @Thorium
- New handlers added to improve security aspects, like
safeRedirectTo,safeRedirectToExt,validateCsrfTokenExtand more. Those deal with:- URL validation in
redirectToto prevent cross-site scripting (XSS) - Cross-Site Request Forgery (CSRF) token validation helpers
- URL validation in
- XML serializer's
Deserialize<'T>(xml: string)method now uses a configuration to prevent XXE attacks. redirectTohandler now marked as Obsolete.
- New handlers added to improve security aspects, like
- Could we avoid allocation of UTF8 byte array? - Credits @Thorium
- Remove [<AllowNullLiteral>] attribute from Json.ISerializer and Xml.ISerializer - Credits @64J0
- With the release of .NET 9 we have nullable reference types.
- When this feature is enabled (
<Nullable>enable</Nullable>), our users started running into problems that boils down toJson.ISerializerhaving theAllowNullLiteralattribute. - Due to it, we decided to remove this attribute from both the
Json.ISerializerand theXml.ISerializer.- New automated tests were added to assert that the serializers are still working properly.
- We also updated some sample projects to use this feature.
- Update fsharp-analyzers and the analyzer packages - Credits @Numpsy
- Improve JSON docs - Credits @64J0
- Add issue templates - Credits @64J0
- Enhance routef support for named parameters and improve documentation - Credits @RJSonnenberg
With this release, we're improving the codebase a bit by fixing warnings triggered by Ionide.Analyzers, and adding .NET 9 as a target framework to the project.
Other than that, we're adding new router functions for the EndpointRouting module which will let the user interact with Giraffe's ConfigureEndpoint directly. This will let you use Asp.Net extensions directly, like rate limiting, response caching, etc. Just remember its type definition:
type ConfigureEndpoint = IEndpointConventionBuilder -> IEndpointConventionBuilderAnd here we have the list of PRs related to this release:
- Add GitHub dependabot configuration - Credits @64J0
- Add global rate limiting sample - Credits @64J0
- Add OpenApi section to the documentation - Credits @64J0
- Add AssemblyVersion attribute - Credits @64J0
- Add more links - Credits @64J0
- Code scanning fix patches - Credits @64J0
- Add .NET 9 as target framework, fine-tune dependabot, update CI and clean tests removing .NET 6/7 from target frameworks - Credits @64J0
- [Alpha] Add Endpoint routing functions ...WithExtensions - Credits @64J0
Combination of the tags:
- Add maintainers info - Credits @nojaf
- Fix ReadBodyFromRequestAsync disposing ctx.Request.Body - Credits @64J0
- Moar fantomas - Credits @nojaf
- Format all F# source code using fantomas.
- Started checking the
samples/,tests/andsrc/contents to know if they are complying with fantomas format.
- HandleOptionGracefullyAnalyzer for ETag and Last-Modified at Preconditional.fs - Credits @64J0
- feat: add request limits on accept, content-type, and content-length headers - Credits @stijnmoreels
- Add request guards/limitation on:
AcceptheaderContent-TypeheaderContent-Lengthheader
- Add request guards/limitation on:
- Add F# Analyzers - Credits @1eyewonder
- Add F# compatible json serializer - Credits @fpellet
- Add F# compatible json serializer with
FSharp.SystemTextJson:Json.FsharpFriendlySerializer
- Add F# compatible json serializer with
- Update .vscode samples debug configuration - Credits @64J0
Combination of the tags:
NewtonsoftJsonandSystemTextJsonmodules are removed, the latter is now moduleJson, NewtonSoft is not supported anymore, see PR Promote System.Text.Json as default JSON serializer.- For more information, check the updated JSON documentation section: link. This has instructions on how to setup
NewtonsoftJsonback if you need to keep it for your project.
- For more information, check the updated JSON documentation section: link. This has instructions on how to setup
- Add ability to Configure Endpoints via IEndpointConventionBuilder - Credits @mrtz-j
- This PR enables us to reuse some of the built-in OpenApi generation to generate OpenApi schemas from code.
- There's an example mentioned at the PR description, and a complete sample project available at this repository.
- It was inspired by Oxpecker from @Lanayx.
- Improve DEVGUIDE with SemVer pre-release observation - Credits @64J0
- Promote System.Text.Json as default JSON serializer - Credits @esbenbjerre
- This PR removes the Newtonsoft JSON serializer and promotes System.Text.Json as the default.
- The JSON section of the documentation was updated, showing how someone could configure the project to use the Newtonsoft JSON again.
- Fix pre-release/release workflows - Credits @64J0
- Hotfix pre-release workflow - Credits @64J0
- Update README.md giraffe-template installation command - Credits @dbrattli
- Change dev instructions and CI - Credits @64J0
- Fix EndpointRouting Guid regex + tests - Credits @64J0
- Upgrade to .NET 8 - Credits @Banashek @fpellet
- Improve CI by updating actions version and avoid concurrent jobs for the same PR - Credits @64J0
- Add Fantomas validation to CI - Credits @64J0
- Upgrade to .NET 8 - Credits @Banashek @fpellet
- Same as 6.3.0
- No need to build so many Regex - Credits @Thorium
- Minor code optimisation - Credits @Thorium
- Fix requiresAuthentication for null user identity - Credits @rslopes
- Add explicitly the statement that the usage of Giraffe.EndpointRouting is recommended - Credits @64J0
- Add an example app using the cache features - Credits @64J0
- Change sample EndpointRoutingApp level - Credits @64J0
- Add GetWebHostEnvironment function and add deprecation warning to GetHostingEnvironment - Credits @64J0
- remove Utf8Json support - Credits @jcmrva
- Updating github workflow file to use nuget-acceptable version numbers for packaging - Credits @Banashek
- Updating mimetype accept header parsing to use builtin aspnet parse/methods - Credits @Banashek
- Make recyclableMemoryStreamManager internal - Credits @kerams
- Upgrade to .NET 7 - Credits @epoyraz
- Documentation: Add another tutorial video to README - Credits @SIRHAMY
- Fixed Slack invite link - Credits @anpin
- RFC-compliant Content-Length handling for 1xx, 204 and 205 responses and CONNECT requests - Credits @retendo
- Fix spelling in docs for BindJsonAsync and BindXmlAsync - Credits @onpikono
- Restore 6.0 as TFM - Credits @TheAngryByrd
- Same as 6.0.0-alpha-2
- Added
setContentTypehandler - Made the
RecyclableMemoryStreamManagerconfigurable through DI - Improved
Xml.Serializerto also make use of theRecyclableMemoryStreamManager
Upgraded to .NET 6 and F#'s new native task computation expression.
Stable release of latest 5.0.0 RC with additional XML comment fixes to comply with latest F# compiler services.
Updated Ply from 0.1.* to 0.3.*.
Replaced TaskBuilder.fs with Ply for Giraffe's task computation expressions. Please see #421 for more information.
This was a change long in the making and has been factored into the 5.0.0 release. Ply is being actively developed by Crowded and has better exception stack traces for task computations and several performance improvements over TaskBuilder.fs.
- Fixed bug when a
NestedEndpointpreceded aMultiEndpointinGiraffe.EndpointRouting(see #452) - Removed the sub-module
GiraffeMiddlewarefrom theGiraffe.EndpointRoutingmodule (simply keep using theUseGiraffeextension method of anIApplicationBuilder) - Added an overload for
UseGiraffeto pass in anEndpoint list:- Before:
app.UseEndpoints(fun e -> e.MapGiraffeEndpoints(endpoints))
- Now:
app.UseGiraffe(endpoints)
- Before:
- Added
ReadBodyBufferedFromRequestAsyncextension method to buffer and read a the request body and make subsequent reads possible (see #449) - Changed how the serialization modules are structured:
IJsonSerializeris nowJson.ISerializerUtf8JsonSerializeris nowUtf8Json.SerializerNewtonsoftJsonSerializeris nowNewtonsoftJson.SerializerSystemTextJsonSerializeris nowSystemTextJson.SerializerIXmlSerializeris nowXml.ISerializerDefaultXmlSerializeris nowSystemXml.Serializer
- Converted all
HttpContextextension methods into C# compatible extension methods, meaning that function arguments had to be merged into tuples - Removed the
=>operator fromGiraffe.EndpointRouting - Changed the
GET,POST,PUT,HEAD, etc. functions to accept anEndpoint listinstead of anEndpoint- Before:
GET => route "/foo" (text "bar"), After:GET [ route "/foo" (text "bar") ] - One can now compose routes easier:
GET [ route "/a" (text "A") route "/b" (text "B") route "/c" (text "C") ]
- Before:
- Added
GET_HEADto the endpoint routing functions, which will handle aHEADrequest for the sameGEThandler.
- Fixed pre-conditions validation issue (see #424)
- Fixed parsing issue with Guids and ShortIds in
Giraffe.EndpointRouting(see #447) - Added
routexphttp handler to default router (see #446)
Upgraded to .NET 5. The 5.x version of Giraffe is targeting net5.0 and dropping support for all other target frameworks. If you cannot upgrade a project to .NET 5 yet then stay on an older version of Giraffe until you can. Giraffe has always been a .NET Core centered project and in the .NET Core world (and now .NET 5 world) there is little to no reason why a project should remain on an old .NET Core version for a long time when upgrade paths are mostly as simple as changing the <TargetFramework> property in an .fsproj file.
-
Only supported target framework is .NET 5
-
Added
Giraffe.EndpointRoutingnamespace with a version of a few routing handlers which integrate with ASP.NET Core's endpoint routing API- Currently supported are:
route,routef,subRouteand HTTP verb handlers such asGET,POST,PUT, etc. - Check the Endpoint Routing documentation for more details
- Or check the
EndpointRoutingAppsample app for how to useGiraffe.EndpointRouting
- Currently supported are:
-
Replaced
Giraffe.GiraffeViewEnginewith the standalone NuGet packageGiraffe.ViewEngine -
New
JsonOnlyNegotiationConfigfor setting a content negotiation policy which only supports JSON serialisation (no XML for those who don't need it) -
Added
SystemTextJsonSerializerwhich usesSystem.Text.Jsonfor JSON serialisation when configured as the desired JSON serializer in Giraffe -
Improved RegEx http handlers in original (non Endpoint routing) http handlers
-
Swapped Markdown docs for XML docs for all functions.
-
Added support for complex model binding (see #416)
- Enhanced Endpoint routing with a metadata list (see PR #437)
- Swapped Markdown docs for XML docs for all functions.
- Improved endpoint routing by deferring the creation of
RequestDelegatefunctions. - Added dependency to new
Giraffe.ViewEnginepackage and re-introduced thehtmlViewandWriteHtmlViewAsyncfunctions into Giraffe. - Added support for complex model binding (see #416)
- Only supported target framework is .NET Core 3.1 (in preparation for .NET 5)
- Added
System.Text.Jsonserializer - Added
Giraffe.EndpointRoutingnamespace with a super early alpha version of new routing handlers which integrate with ASP.NET Core's endpoint routing API (check out theEndpointRoutingAppsample app for examples before the documentation is ready) - Removed
Giraffe.GiraffeViewEngine(in preparation to distribute it as a separate NuGet package, which doesn't exist yet). This release has noGiraffeViewEnginewhich is one of the reasons why it's analpha-001release. Plans are to bring it back in5.0.0-alpha-002 - New
JsonOnlyNegotiationConfigfor setting a content negotiation which only supports JSON serialisation and not XML - Improved RegEx http handlers in original (non Endpoint routing) http handlers
- Added
SystemTextJsonSerializerwhich usesSystem.Text.Jsonfor JSON serialisation when configured as the desired JSON serializer in Giraffe
- Removed redundant dependencies
- Fixed model binding for arrays (see #403)
- Fixed pre-condition bug for the
If-Unmodified-SinceHTTP header (see #402) - Added
netcoreapp3.1support
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
DateTimeextension methodToIsoStringwhich produces a RFC3339 formatted string, and corrected the docs on the existingToHtmlStringextension method which actually produces a RFC822 formatted string.
-
Fixed
routefto not match more than one URL path segment. -
Fixed the
_ariaLabelledByattribute in theGiraffeViewEngine -
Fixed case insensitive route handlers on Ubuntu
-
Changed minimum version of
Newtonsoft.Jsonto11.0.2. This allows Giraffe to be compatible with Azure Functions. -
Renamed
tryMatchInputtotryMatchInputExactand swapped the order of arguments so that the string value comes last -
Added new version of
tryMatchInputwhich acceptsMatchSettingsrecord: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
subRouteCihttp handler, which prevented nested sub routes to be case insensitive.
- Added two new
HttpContextextension 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_HEADhttp handler (see: #314 for more info). - Added a new convenience function called
handleContext, which can be used for creating newHttpHandlerfunctions.
- Fixed the
_dataattribute in theGiraffeViewEngineto accept akeyandvalueparameter now.
- Added a new http handler called
authorizeRequestto authorize a request based on aHttpContext -> boolpredicate. - Added a new http handler called
authorizeUserwhich is an alias forevaluateUserPolicy. TheevaluateUserPolicyhandler will be removed in the next major release.
- Added
stras an alias for theencodedTextfunction from theGiraffeViewEngine. - Added the
HttpContext.GetRequestUrl()extension method to retrieve the entire URL string of the incoming HTTP request.
- Adding the
charsetparameter in the HTTPContent-Typeresponse 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
validatePreconditionsto 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
SubRoutingmodule: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
htmlViewhandler. - Upgraded to the latest
TaskBuilder.fsNuGet package which also has the SourceLink integration now.
- Fixed the
Successful.NO_CONTENThttp handler, which threw an exception when calling from ASP.NET Core 2.1.
-
Changed the type
XmlNodeby removing theRawTextandEncodedTextunion case and replaced both by a singleTextunion case. The HTML encoding (or not) is being done now when calling one of the two helper functionsrawTextandencodedText.- This change - even though theoretically a breaking change - should not affect the vast majority of Giraffe users unless you were constructing your own
XmlNodeelements which were of typeRawTextorEncodedText(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.ContextInsensitiveversion of the Task CE. This change has no effect on the behaviour oftaskcomputation expressions in Giraffe. In the context of an ASP.NET Core web application there is not difference betweenContextSensitiveandContextInsensitivewhich 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.ContextInsensitivewhere before it might have been sufficient to onlyopen Giraffe. -
Changed the members of the
IJsonSerializerinterface 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
GiraffeViewEngineby changing the underlying composition of views from simple string concatenation to using aStringBuilderobject.
- 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.NewtonsoftJsonSerializeris still the default JSON serializer in Giraffe (for stability and backwards compatibility), butUtf8JsonSerializercan be swapped in via ASP.NET Core's dependency injection API. The newUtf8JsonnSerializeris significantly faster (especially when sending chunked responses) thanNewtonsoftJsonSerializer. - Added a new
HttpContextextension method for chunked JSON transfers:WriteJsonChunkedAsync<'T> (dataObj : 'T). This newHttpContextmethod can write content directly to the HTTP response stream without buffering into a byte array first (see Writing JSON). - Added a new
jsonChunkedhttp handler. This handler is the equivalent http handler version of theWriteJsonChunkedAsyncextension 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
requiresAuthPolicytoevaluateUserPolicyin order to better describe its functionality and to avoid a name clash between two newly added handlers for validating ASP.NET Core'sAuthorizationPolicyobjects (see new features). - Changed how he
AddGiraffe()extension method registers Giraffe dependencies in ASP.NET Core. It now follows theTryAddpattern which will only register a dependency if it hasn't been registered beforehand. - Changed the
HttpContext.GetService<'T>()extension method to throw aMissingDependencyExceptionif it cannot resolve a desired dependency.
- Added two new http handlers to validate an ASP.NET Core
AuthorizationPolicy(see: Policy based authorization). TheauthorizeByPolicyNameandauthorizeByPolicyhttp handlers will use ASP.NET Core's authorization service to validate a user against a given policy. - Updated
TaskBuilder.fsto version2.0.*. - Updated ASP.NET Core NuGet packages to latest
2.1.*versions. - Enabled
return!foropt { }computation expressions. - Added
blockquote,_integrityand_scopedto 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.Accessibilitymodule. - Added a new
Successful.NO_CONTENThttp handler which can be used to return a HTTP 204 response. - Added more structured logging around the Giraffe middleware.
- Fixed a bug in
routef,routeCifandsubRoutefwhich prohibited to parse multiple GUIDs - Fixed a bug in
routef,routeCifandsubRoutefwhich 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 aPATCHorDELETEhttp request.
- Added
subRoutefhttp handler (see subRoutef) - Added
routexandrouteCixhttp 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.
routeBindworks when nested in asubRoutehandler nowrouteBinddoesn'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,CONNECThttp handlers - Added more
HttpContextextension methods to create parity between response writing methods andHttpHandlerfunctions (see Response Writing and Content Negotiation) - Added detailed XML docs to all public facing functions for better Intellisense support
- The
Giraffe.Commonmodule 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.TokenRouterlibrary 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>,serializeXmlanddeserializeXml<'T>
- Removed
- Removed the
customJsonhttp handler - Renamed the
htmlhttp handler tohtmlString - Renamed the
renderHtmlhttp handler tohtmlView - Renamed
setBodyAsStringhttp 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>andWriteJsonAsyncwhich accepted an object of typeJsonSerializerSettings - Renamed the
signOffhttp handler tosignOutto 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
portRoutetoroutePortsto be more consistent with other routing functions (route,routef,routeStartsWith, etc.)
routefandrouteCifboth support%Ofor matchingSystem.Guidvalues now- Added HTML attributes helper functions to the
GiraffeViewEngine.
Example:
let html = p [ _class "someCssClass"; _id "greetingsText" ] [ encodedText "Hello World" ]- Renamed
Giraffe.XmlViewEnginetoGiraffe.GiraffeViewEngineas it represented more than just an XML view engine.
- Added automatic validation of the format string inside
routefandrouteCifto notify users of the notorious%dvs%ierror during startup.
- Fixed
ReadBodyFromRequestAsyncwhere 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
htmlhttp handler which can be used to return atext/htmlresponse by passing in the html content as a string variable
- Added a new overload for
GetLoggerof theHttpContextextension methods, which allows one to pass in acategoryNamestring in order to initialise a new logger:let logger = ctx.GetLogger "categoryName". BindFormAsync,BindQueryStringandBindModelAsyncaccept an additional optional parameter forCultureInfo.
- Removed
Giraffe.Tasksfrom theGiraffeNuGet package and added a new dependency on the newly createdGiraffe.TasksNuGet package. You can use theGiraffe.TasksNuGet package from non ASP.NET Core projects now as well.
- Added HTTP status code helper functions.
- Added
defaultSerializeJsonanddefaultDeserializeJsonmethods. - Auto opened default Giraffe modules so that the core functionality can be entirely consumed through a single
open Giraffestatement. - The functionality from
Giraffe.Razor.MiddlewareandGiraffe.Razor.HttpHandlerscan be both consumed through a singleopen Giraffe.Razornow.
- Changed the
basetag from theXmlViewEnginefrom a regulartagto avoidTagto comply with the HTML spec.
- Renamed all async methods by appending
Asyncat the end of the method in order to comply with the general .NET naming conventionreadFileAsString-->readFileAsStringAsyncctx.ReadBodyFromRequest-->ctx.ReadBodyFromRequestAsyncctx.BindJson-->ctx.BindJsonAsyncctx.BindXml-->ctx.BindXmlAsyncctx.BindForm-->ctx.BindFormAsyncctx.BindModel-->ctx.BindModelAsyncctx.WriteJson-->ctx.WriteJsonAsyncctx.WriteXml-->ctx.WriteXmlAsyncctx.WriteText-->ctx.WriteTextAsyncctx.RenderHtml-->ctx.RenderHtmlAsyncctx.ReturnHtmlFile-->ctx.ReturnHtmlFileAsync
- Renamed
Giraffe.DotLiquid.HttpHandlersmodule toGiraffe.DotLiquid
- Added
portRoutehttp handler to filter an incoming request based on the port
- The
GET,POST,PUTandDELETEhttp handlers of theTokenRouter.fshave changed to accept a list of http handlers now.
- TokenRouter fringe case not being identified before (see #150)
- Added
requiresAuthPolicyhttp handler - Added
RenderHtmlandReturnHtmlFileextension methods to theHttpContextobject - Added
customJsonhttp handler, which allows users to define a custom json handler (with custom serialization settings) - Added overloads to
BindJsonandBindModelwhere a user can pass in a customJsonSerializerSettingsobject
- 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.DefaultSettingsobject - usecustomJsoninstead if customization is required) - Changed the
serializeJson,deserializeJsonmethods to accept an aditional parameter of typeJsonSerializerSettings
- Automatically URL decoding of string values when using
routef - Fixed an inference bug with
routefby replacing theformatparameter of thetryMatchInputmethod and thepathparameter of theroutefandrouteCifmethods fromStringFormattoPrintFormat - 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
htmlFilehttp handler by allowing thefilePathparameter to be either rooted or relative to theContentRootPath
- Added three additional
HttpContextextension methods in theGiraffe.HttpContextExtensionsmodule:WriteJson,WriteXmlandWriteText. These three methods can be used for direct HttpReponse writing from within a custom handler without having to sub-call thejson,xmlortexthttp handlers. - Changed the
UseGiraffeErrorHandlermethod to return anIApplicationBuildernow. This change allows middleware chaining. This is a breaking change and you'll either have to chain middleware or append an|> ignorein 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
readFileAsStringclosed the stream before the file could be read
- Fixed bug so that
_ViewStart.cshtmlfiles get respected now
- Fixed wrong version numbers in package references for
GiraffeandGiraffe.Razor
- Fixed the
warblerfunction. 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
routeBindhttp handler - Annotated all default http handler functions with the
HttpHandlertype
- Fixed build error in the Giraffe template.
- Renamed
renderXmlStringtorenderXmlNodeand renamedrenderHtmlStringtorenderHtmlNode - Added two more methods which accept a
XmlNode list:renderXmlNodesandrenderHtmlNodes - Changed the return value of
encodedTextandrawTextto return a singleXmlNodeinstead 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.HtmlEnginemodule toGiraffe.XmlViewEngine - Renamed
HtmlAttributetoXmlAttribute,HtmlElementtoXmlElementandHtmlNodetoXmlNode - Renamed and make the function
nodeToHtmlStringprivate - Added
commentfunction to theGiraffe.XmlViewEnginemodule for creating XML comments - Added
renderXmlStringandrenderHtmlStringfunctions toGiraffe.XmlViewEnginemodule for rendering XML and HTML nodes.
- Changed
HttpContext.BindQueryString<'T>()to return'Tinstead 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.RazorGiraffe.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
HttpContextextension 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/textas a new supported mime type to the defaultnegotiatehandler (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
HttpContextobject:ctx.GetService<'T>()andctx.GetLogger<'T>()
- Completely removed the
HttpHandlerContexttype and replaced all usage with the originalHttpContextobject from ASP.NET Core. - Extended the
ErrorHandlerfunction with a parameter to retrieve a defaultILoggerobject - Moved model binding functions from the
Giraffe.ModelBindingmodule into theGiraffe.HttpContextExtensionsmodule and made them extension methods of theHttpContextobject
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
bindQueryStringwhich can automatically bind a model from query string parameters - Extended
bindModelto includebindQueryStringwhen the HTTP method is notPOSTorPUT
- Added a
warblerfunction - Added model binding capabilities which can automatically bind a HTTP payload to a strongly typed model:
bindJson,bindXml,bindFormandbindModel
- Improved the
negotiateWithandnegotiatehttp handlers by making use of ASP.NET Core'sMediaTypeHeaderValueclass - Added
*.cshtmlfiles to the DotNet watcher in the template
- Fixed
AssemblyNameandPackageIdvalues in the template
Added two new HttpHandler functions:
negotiatechecks theAcceptheader of a request and determines automatically if a response should be sent in JSON or XMLnegotiateWithis 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
HttpHandlernamedrenderHtmlto return views from the new view engine
- Updated
Newtonsoft.Jsonto version10.0.* - Updated the Giraffe
dotnet newtemplate
- 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-templatewhich is a newdotnet newtemplate for Giraffe projects - Removed
RazorLightas a dependency and replaced it with the official razor engine by ASP.NET Core MVC - Renamed the HttpHandler
htmlTemplatetodotLiquidHtmlView - Added a new HttpHandler named
dotLiquidTemplate. The difference is that it let's the caller decide whatContent-Typethe response shall be. - Renamed the HttpHandler
razorViewtorazorHtmlView - Added a new HttpHandler named
razorView. The difference is that it let's the caller decide whatContent-Typethe 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.HostingtoMicrosoft.AspNetCore.Hosting.Abstractions - Added
razorViewHttpHandler
This version has some breaking changes
- Re-factored
bindto make it a true bind function - Added a new
composecombinator - The
>>=operator became>=>now and>>=is the newbindfunction (Fixes #5) - Upgraded project to .NET Core SDK RC4
- Upgraded to FSharp.Core 4.1.0
- Added
subRouteandsubRouteCihandlers (Fixes #7 ) - Uses culture invariant parse functions for
routefandrouteCif(See #8)
- Changed the
HttpHandlerContextto include anIServiceProviderand removedIHostingEnvironmentandILoggerFactoryinstead - Added more default HttpHandlers:
challenge,signOff,requiresAuthentication,requiresRole,requiresRoleOf,clearResponseandxml - 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
ErrorHandlerMiddlewaretoLambdaErrorHandlerMiddlewareand changed theIApplicationBuilderextension method toUseLambdaErrorHandler
First alpha release with a basic set of functionality.