0

In flask, I do

from flask import request

route = request.url_rule.rule if request.url_rule else request.path

So that I can get the "original" URL registered in Blueprint.

For example, when API http://localhost/v1/user/001 was called, I'd got route's value /v1/user/<user_id> -- the "original" URL I want, for the next operations.

How do I achieve that with GO?

--

I added up some information as below comments

romlym
  • 561
  • 1
  • 7
  • 26
  • 1
    This is not supported by the standard library out of the box. Adding it yourself shouldn't require any real effort though. What have you tried? What problems did you encounter? Asking for external library recommendation is considered off-topic on StackOverflow. – mkopriva Sep 20 '22 at 11:05
  • @mkopriva Yes, you were right, I'll edit my question. Besides, I'm doing this for proxy authorization issues, I need to know what kind of API (or URL) was called, and do some judgment. Also, I've tried using `regex` to analyze the calling URL, like manually picking up the URL parameters and making up the `original` PATH. – romlym Sep 21 '22 at 02:48
  • @mkopriva In fact I'm asking for a more elegant and efficient way to do that, so I asked for suggestions of external libraries. But you are right it's not a StackOverflow question, sorry – romlym Sep 21 '22 at 02:54

0 Answers0