I want to retrieve a value from a URL. Provided I have a URL such as http://myurl.com/theValue1/iWantToRetrieveThis
, I want to split this value and want to retrieve theValue1
and iWantToRetrieveThis
. How can I do this?
I tried the code below but it seems that it's only retrieving the query string:
func decodeGetTokenRequest(_ context.Context, r *http.Request) (request interface{}, err error) {
fmt.Println("decoding here", path.Base(r.URL))
return getTokenRequest{
SellerID: r.URL.Query().Get("sellerid"), <<--- THis is empty
Scope: r.URL.Query().Get("scope"), <<-- This is also empty
Authorization: Validation{
credential: r.Header.Get("ETM-API-AUTH-KEY"),
},
}, nil
}