Adding Context Items for services
See original GitHub issueI implemented a custom client filter:
public class AppendIdentifierFilter: IClientFilter
{
public async ValueTask<ResponseContext> SendAsync(RequestContext context, Func<RequestContext, ValueTask<ResponseContext>> next)
{
context.Items.Add("test", "foo);
return await next(context);
}
}
and tried to access it in my service on the server-side:
public async UnaryResult<Nil> Test()
{
Logger.Info($"we have the items {string.Join(", ", Context.Items.Keys)}");
....
But the items dictionary appears to be empty.
To initialize the service I used the following way:
MagicOnionClient.Create<ITestService>(_channel, new IClientFilter[]
{
new AppendIdentifierFilter(_identifier),
});
From the documentation, I could not figure out what part was still missing.
Thank you for any help
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Add context menu items to services (windows)
I am trying to a delete option to the right click menu of windows services, I know that you can do this with...
Read more >How to add a mac OS service item directly in the contextual ...
I want my context menu item directly in the context menu regardless of how many services does the particular user has enabled. –...
Read more >chrome.contextMenus - Chrome Developers
Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions...
Read more >Access HttpContext in ASP.NET Core
HttpContext encapsulates all information about an individual HTTP request and response. An HttpContext instance is initialized when an HTTP ...
Read more >Adding a list of objects to Context Data returned by Layout ...
I was working on a project that needed some data passed on through the context. Logic was implemented based on https://jss.sitecore.com/docs/ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry. Certainly the example code does not work properly. To add a header to the request, use
WithHeaders
method.There are no sharings between
RequestContext
(Client) andCallContext
(Server). For example, you can useCallContext.Items
for sharing values between MagicOnionFilters and a service method in the server-side per call.If you want to pass the key-values with request from client to server, use
RequestContext.CallOptions.Headers
(Client) andCallContext.RequestHeaders
(Server).