-
-
Notifications
You must be signed in to change notification settings - Fork 992
Storing request specific context in Got #740
Copy link
Copy link
Closed
Labels
🎁 Rewarded on IssuehuntThis issue has been rewarded on IssuehuntThis issue has been rewarded on IssuehuntenhancementThis change will extend Got featuresThis change will extend Got featuresgood for beginnerThis issue is easy to fixThis issue is easy to fix✭ help wanted ✭
Milestone
Description
Metadata
Metadata
Assignees
Labels
🎁 Rewarded on IssuehuntThis issue has been rewarded on IssuehuntThis issue has been rewarded on IssuehuntenhancementThis change will extend Got featuresThis change will extend Got featuresgood for beginnerThis issue is easy to fixThis issue is easy to fix✭ help wanted ✭
What would you like to discuss?
I would like to instrument a Got instance using
beforeRequest,afterResponseandbeforeErrorhooks. The plan is to create a new request context for each request in thebeforeRequesthook and then access that context in theafterResponseandbeforeErrorhooks to report the request's success/error status.The natural way to do this would be to just mutate the options object in
beforeRequestand set a new property containing the context, this is easy to access in bothafterResponseandbeforeErrorthrough thegotOptionsgiven. My only worry is that by introducing new properties in the options there might be incompatibilities with other hooks or later versions of Got itself.Are there any guidelines or rules of how to name custom variables inside options? Or alternatively is there any better place where I could store my custom property? I plan to release my instrumentation as a public library, so I just want to confirm that I'm not doing anything wrong here.
Checklist
IssueHunt Summary
[
<
i
m
g
s
r
c
'
h
t
t
p
s
:
/
/
a
v
a
t
a
r
s
0
.
g
i
t
h
u
b
u
s
e
r
c
o
n
t
e
n
t
.
c
o
m
/
u
/
3
6
8
9
4
7
0
0
?
v
4
'
a
l
t
'
s
z
m
a
r
c
z
a
k
'
w
i
d
t
h
2
4
h
e
i
g
h
t
2
4
s
z
m
a
r
c
z
a
k
]
(
h
t
t
p
s
:
/
/
i
s
s
u
e
h
u
n
t
.
i
o
/
u
/
s
z
m
a
r
c
z
a
k
)
h
a
s
b
e
e
n
r
e
w
a
r
d
e
d
.
Backers (Total: $60.00)
Submitted pull Requests
userDataoptionTips
IssueHunt has been backed by the following sponsors. Become a sponsor