I am trying to create a Listener (that listens multiple routes). But I don't manage to find the right solution. My problem is : I am running locally Ngrok (on my 8000 port), and an API is sending JSON (with REST request) to my ngrok address. How can I correctly listen the routes called by the API in CSharp ?
-
Nope ! Do you have an example ?Anthony D'Amato– Anthony D'Amato2015-09-21 22:25:00 +00:00Commented Sep 21, 2015 at 22:25
-
Sorry, I deleted my comment and posted it as an answer. The topic is a bit large to provide an example in a Stackoverflow answer, but if you look at the "getting started" tutorials, you should get the idea pretty quickly.Thomas Levesque– Thomas Levesque2015-09-21 22:28:41 +00:00Commented Sep 21, 2015 at 22:28
Add a comment
|
2 Answers
Have you considered ASP.NET Web API? Looks like it's exactly what you need.
9 Comments
Anthony D'Amato
That's too complex for what I want I think. I am searching for something like "http.HandleFunc()" in Go.
Thomas Levesque
@AnthonyD'amato, too complex for what? Your requirements aren't very clear. What do you want to do with the API requests? Send a response, or just intercept them?
Anthony D'Amato
Yes.. Sorry. I just want to intercept them, read them and send a HTTP 200 as response.
Anthony D'Amato
For example : The API sends a POST request at 8376de2f.ngrok.io/actions/light/start (an http tunnel generated by Ngrok) sending a json, and I want to intercept this request.
Thomas Levesque
@AnthonyD'amato, you can use an HttpListener
|
I have found the solution. My route was : http://localhost:8000/foo/bar To correct the problem, I have changed the route in : http://+:8000/foo/bar
Hope this will help.