Comments (11)
This may sound like a nuanced answer, but "when in Rome..." In other words, having a library that deviates from std lib conventions can hurt its chances of adoption. I am a big fan of passing the context explicitly, especially when designing business service APIs, because it encourages developers to pass it around and make use of it (e.g. respect cancellation signals). But given that std lib chose a different approach for http.Request
, I would make an exception and stick with the std lib API. @yutongp's dual source of truth argument makes a lot of sense.
On a separate note, I thought Fx would be integrated with yarpc and this whole question would become a moot point, since people won't be writing http handlers explicitly, but rather yarpc handlers that do pass context as argument.
from fx.
BTW I do agree context should be the first param in all business logic layers passed HTTP layer. So the user define HTTP handler probably looks like:
func (h Handler) ServeHTTP(w ResponseWriter, r *Request) {
ctx := r.Context()
businessReq := toBusinessModel(r)
businessResp := handleBusiness(ctx , businessReq)
....
}
from fx.
I can put out a diff for this during weekend. It is more about what direction we would like to go. Any thought?
from fx.
We discussed this at length, and were encouraged by the observability team to make it an explicit parameter.
from fx.
I feel like yarpc doesn't have all the features for a pure Go HTTP service (why pure HTTP service? that could be another discussion) for now. Just leak of supporting url-encoded data and user unable to set http response code is almost a No for a lot of use cases. So for now having a http package with all the tool chains we need make sense I think.
from fx.
@yutongp for yarpc http is just a protocol. We have a separate uhttp module, which has nothing to do with yarpc whatsoever.
from fx.
I think @yutongp caught us in the transition state: we just removed a custom fx.context and haven't fully moved to use the standard one yet.
from fx.
@alsamylkin I like you guys changed fx to use std context. When I saw that commit, I said 'YES!' to myself. I think std context is definitely the direction to go. appengine
used to have custom context and they moved away.
from fx.
from fx.
@sectioneight sure, no worries, no rush :D
from fx.
from fx.
Related Issues (20)
- fx.Decorate does not add a missing object to the module HOT 3
- When combining fx.As to annotate return type as interface with optional parameters nil value check is not working as expected HOT 1
- Startup order isn't preserved when using modules HOT 3
- Example test failing in master branch when port 8080 is already in use (89f4a90) HOT 3
- fxevent.Logger: Silence until there's an error
- Slog adapter for fx HOT 4
- Release method HOT 10
- fxtest.Lifecycle: Enforce timeout
- Impossible to inject struct that is part of a group by itself HOT 2
- Support Multiple ParamTags? HOT 1
- signalReceivers should call `Signal.Stop(recv.signals)` when stopped
- Release v1.22.0
- Private supplies HOT 1
- Support multiple ResultTags annotations
- Opt-out of signal handling HOT 12
- Add constructor runtime to fxevent.Run events
- Ability to use fx.As and fx.ResultTags for the same Provider HOT 1
- Deadlock in `signalReceivers.Stop` HOT 6
- Decorate does not work if inside fx.Module and Populate is called from outside Module HOT 6
- Quieter fxtest logger
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 fx.