am trying of create dynamic URL in DataTable with golang
The idea is to have some icons that remove an element from the table
The columns are created in the controller by directly passing the link all this after consulting the BDD where the variable "id" concatenated in the string represents each element
cadenaS := "<a class='links' href='/history/search/" + id + "'><i class='fas fa-search' aria-hidden='true'></i></a>"
cadenaT := "<a class='links' href='/history/delete/" + id + "'><i class='far fa-trash-alt' aria-hidden='true'></i></a>"
his = append(his, History{ID: ID, Email: Email, Search: Search, Tipo: Tipo, Visited: Visited, Icon: &Icon{Search: cadenaS, Trash: cadenaT}})
To show it, the call is simply made with a response json
"columns": [
{"data": "Icon.Search"},
{"data": "Search"},
{"data": "Visited"},
{"data": "Icon.Trash"}
],
the URL that will receive the request to delete the item
http.HandleFunc("/history/delete/{id}", deleteHistory)
but never manages to make the call because the "ID" in the URL is not recognizing
The standard http
package does not allow URL variables. There are a few packages that do, for example gorilla mux is quite popular and can do that for you.