Middleware Pattern For HttpClient With Delegating Handlers

  Рет қаралды 15,264

Milan Jovanović

Milan Jovanović

Күн бұрын

Пікірлер: 53
@ThrottleScotty
@ThrottleScotty Жыл бұрын
Excellent timing - I just completed the Authentication section of your Pragmatic Clean Architecture course and wanted to learn more about this point specifically. Thanks!
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Awesome, glad this was helpful to add more details 🔥
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@johnnyirish9852
@johnnyirish9852 Жыл бұрын
Very nice video on an interesting topic. Ideas for continuing on this: write unit tests for this, write a handler that manages redirects (I think that would need to be the lowest handler, and be a different type than DelegatingHandler)
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Where would we be redirecting? 🤔
@johnnyirish9852
@johnnyirish9852 Жыл бұрын
​@@MilanJovanovicTech It would be for example a handler that just logs redirect links. in the case you navigate to a link provided by the user and you want to log potential redirects, when you try to download from the user provided link.
@kodindoyannick5328
@kodindoyannick5328 6 ай бұрын
Thank so much Milan. I understand better this concept with your explanation.
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Glad it was helpful :)
@nove1398
@nove1398 Жыл бұрын
Clean thumbnail, really good content.
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
You like the thumbnail? I started working with an editor
@quocboy159
@quocboy159 Жыл бұрын
this is brilliant. I was wondering if you could help me explain when we should use transient, scope, and singleton in DI for the practical case?
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Transient - stateless and lightweight services Scoped - one instance per scope (an HTTP request is a scope) Singleton - one instance per app
@10Totti
@10Totti Жыл бұрын
Best tutorial!
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Thank you!
@Th3MoL3
@Th3MoL3 Жыл бұрын
Hmmmm......i was getting a bit of déjà vu as i was thinking i had seen this in a video already very recently. Nick Chapsas literally had a video talking about this 4 days ago....maybe its a coincidence 👀
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
It is, I schedule my videos 2-4 weeks in front 📆📆
@pp-studio
@pp-studio Жыл бұрын
Thank you for your content.
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Don't mention it, glad it was valuable!
@PhucHuuNguyen-p2v
@PhucHuuNguyen-p2v Ай бұрын
nice work.Thanks. Can you do the tutorial about header propagation in asp .net core api. Thanks
@MilanJovanovicTech
@MilanJovanovicTech Ай бұрын
Noted
@codecam9213
@codecam9213 Жыл бұрын
how to solve this : Bearer error="invalid_token", error_description="The signature key was not found" when using http client in blazor
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
No idea
@microtech2448
@microtech2448 Жыл бұрын
Let's say there are 3 external APIs meaning their base address, authentication process would be different and only one of them would be called based on user input. In that case how would you register them in the startup with message handlers without duplicating code? Thank you.
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Create an extension method that will apply the specific message handlers. But you will still have to call that method for each HttpClient.
@jaans3712
@jaans3712 Жыл бұрын
Do you have a video about Keycloak? Interesting topic
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
No, I don't have a Keycloak video on the channel. However, I did cover Keycloak in the Auth section of my course. But it's not free 😅
@jaans3712
@jaans3712 Жыл бұрын
@@MilanJovanovicTech you salesman!
@pigrebanto
@pigrebanto 7 ай бұрын
Maybe it is more naive apporach but there is also a way to nest Http Handlers within constructors; something like: var client = new HttpClient( new myHttpMsgHanlder_1( new myHttpMsgHanlder_2( new HttpClientHandler() ) )); how do you see it?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Still prefer using the recommended approach
@TheRealBenSanders
@TheRealBenSanders 9 ай бұрын
This helped me so much. What Theme are you running with?
@MilanJovanovicTech
@MilanJovanovicTech 9 ай бұрын
ReSharper syntax highlighting
@DivljaVoda
@DivljaVoda 11 ай бұрын
I have a problem with this approach, i am logging the request and response that go trough httpClient. I need a scoped Service that logs the data. The problem is that the Scoped service contains properties that are same for the httpRequest comming trough api, controllers, services and httpClients that are called within. The problem is that the scoped logging service is somehow out of scope in the DelegateHandler, i tried HttpContextAccessor, it works when the requests come from API, but the problem comes up when the httpClient is called from a background task, scoped logging service is out of scope - therefore the properties that i have are lost when called within delegation handler. How do i solve that problem, do you have an idea?
@MilanJovanovicTech
@MilanJovanovicTech 11 ай бұрын
That's a design smell to me. Can this be re-implemented to consider that there is no HttpContext in the background task?
@pigrebanto
@pigrebanto 7 ай бұрын
did it fail after 2 times? shouldn't have been 3 times the retry instead? tks
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Yes - I might've sped it up for the presentation :)
@techpc5453
@techpc5453 Жыл бұрын
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
👋
@clashclan4739
@clashclan4739 Жыл бұрын
Title misleading where decorator pattern?
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Fixed it 😁
@ronaldabellano5643
@ronaldabellano5643 Жыл бұрын
Why cant save?
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
What do you mean?
@altkev
@altkev Жыл бұрын
I hope one day videos with goofy faces on thumbnails attract less clicks so that trend can go away. This is a programming channel, do these types of viewer's even click more from that?
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
Then you're hoping for human psychology to go away, and well... that isn't really happening. 😅 What does it matter anyway? The content is what's important. If you like it, you'll watch it. If not, you'll stop watching.
@altkev
@altkev Жыл бұрын
@@MilanJovanovicTech Well my comment is a sign that its resulted in me thinking about and focusing on your thumbnail enough to comment about it, so if that's a positive thing for the channel due to the additional engagement, then I suppose there is no incentive for change. But I will say cringe titles/thumbnails can be polarizing.
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
@@altkev Okay, but does the content deliver on the value? Because if it doesn't, I'm doing something wrong. My other option is doing "normal" thumbnails and getting 30-50% less views. :( KZbin is saturated. Right now, there isn't any other way to stand out. P.S. You may want to skip next Friday's video. Quite an awesome thumbnail if I may say so myself, but probably not to your taste. 😅
@altkev
@altkev Жыл бұрын
​@@MilanJovanovicTech 30-50% less views just by not putting your face on there is extreme. Well regardless of my personal tastes and desire to comment on it, you should certainly do what you need to for your channel's success. My comment was more of a commentary that it is unfortunate that such strategies have to be used in the first place.
@DaliborHomola
@DaliborHomola Жыл бұрын
Thank you, this really helped me 🤎
@MilanJovanovicTech
@MilanJovanovicTech Жыл бұрын
I'm glad it was valuable!
How To Build Loosely Coupled Microservices With MassTransit
23:01
Milan Jovanović
Рет қаралды 34 М.
The RIGHT Way To Use HttpClient In .NET
11:46
Milan Jovanović
Рет қаралды 58 М.
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 203 МЛН
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 8 МЛН
100K Subscribers Special: My Journey, Career Advice, Future of .NET
16:36
Milan Jovanović
Рет қаралды 4,9 М.
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 68 М.
TCP/IP for Programmers
3:03:31
Eli the Computer Guy
Рет қаралды 99 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 61 М.
Implementing API Gateway With Ocelot in ASP.NET Core
13:26
Code Maze
Рет қаралды 3,1 М.
Scheduling Background Tasks In .NET With Quartz
10:51
Milan Jovanović
Рет қаралды 37 М.