C#C
C#3y ago
kurumi

❔ REST API but it is HttpListener only available

Hello there, I got a challenge to write good scalable C# REST API app by using only .NET 7 (instead of ASP .NET) with HttpListener.
So I have some questions:
1) As I understood, it will only one
HttpListener
instance that catch all requests on different endpoints - not dedicated
HttpListener
to dedicated endpoint?
2) After I catch connection, I should do
httpListenerInstance.GetContextAsync()
and then transfer it to
ThreadPool.QueueUserWorkItem
?
3) How to execute some logic on needed endpoint? I found an answer by notifying all endpoints like hey my dudes, it is new connection to
/endpoint
can all of you handle it and execute if needed by checking itself context
by using Observer pattern. But I see it may slower my system, is it any way to notify only 1 needed endpoint class?
4)
ThreadPool.QueueUserWorkItem
or it is better to create custom class which will store
ConcurrentQueue<HttpListenerContext>
with all my connections and then run another Task which will peak and notify endpoint func (see p.2 and p.3)?

Please leave good advices - I can not use sweety ASP .NET.
Was this page helpful?