Comments (4)
Both this continuation update and task were done for performance reasons, you can read blog post I did to explain performance benefits here if your interested.
It's a slightly more complex way of doing the handlers but there is a focus on performance and the consensus was it was worth breaking now for the long run.
If you have anymore issues let me know, happy to help.
from giraffe.
Apologies for this issue. Even though I have updated the latest giraffe-template, the previous versions break now when you pull the beta package from an alpha template. I should have not referenced giraffe with a wildcard in the .fsproj. I will set it to a specific version going forward with the new template releases, but meanwhile if someone runs into this issue you can either pin the latest giraffe alpha package, or preferably update the error handler to match the new beta. You can simplify the error handler even further:
let errorHandler (ex : Exception) (logger : ILogger) =
logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.")
clearResponse >=> setStatusCode 500 >=> text ex.Message
Also please update the giraffe-template by running:
dotnet new -i giraffe-template::0.1.7
from giraffe.
The error handler needs to be updated to use new HttpHandler format such that it additionally accepts a 'HttpFunc' functions as well as 'HttpContext' like 'fun next ctx ->. ..'
In the last line where handlers are composed, instead of 'ctx |> (handler)' you need to apply both parameters to functions like '(handler) next ctx'
from giraffe.
Yes, I understand. Your tip fixed the problem. I can know why this change was made? Is related to the new Task
support #53?
If anyone struggle with it too, the new errorHandler which works is it:
// ---------------------------------
// Error handler
// ---------------------------------
let errorHandler (ex : Exception) (logger : ILogger) (next: HttpFunc) (ctx : HttpContext) =
logger.LogError(EventId(0), ex, "An unhandled exception has occurred while executing the request.")
(clearResponse >=> setStatusCode 500 >=> text ex.Message) next ctx
from giraffe.
Related Issues (20)
- Sample `EndpointRoutingApp` structure is weird HOT 1
- NullReferenceException in requiresAuthentication funciton HOT 1
- Run tests on CI HOT 2
- Add output caching middleware after migrating to .NET 7 HOT 2
- Add output cache for `VaryByValue`
- Migrate to System.Text.Json HOT 1
- Participate on hacktoberfest 2023? HOT 1
- Never decalre reader with `use` on `ctx.Request.Body` HOT 4
- Upgrade to .NET 8 HOT 6
- LinkGenerator doesn't work with routef HOT 1
- Giraffe 6.2 is breaks against Microsoft.IO.RecyclableMemoryStream 3.0.0 HOT 11
- Returning streams, either with WriteStreamAsync or WriteFileStreamAsync or their handler equivalents, is extremely slow HOT 4
- Question: How to approach outside in testing of a micro service? HOT 2
- Guid pattern in endpoint router matches invalid values, throws System.FormatException HOT 3
- Follow-up from "Minor code optimisation #567"
- Update SECURITY.md
- Start using fantomas to validate code submissions with CI HOT 6
- [README] Suggestion for "Getting Started"'s "Doing it manually" HOT 2
- [question] Would it be possible to make `Giraffe.EndpointRouting` case-sensitive? HOT 3
- Remove NuGet API key from the repository HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from giraffe.