These are chat archives for gin-gonic/gin

15th
Nov 2016
Jamie Stackhouse
@itsjamie
Nov 15 2016 07:03
Yeah, if Gin's muxer/router is still relatively close to httprouter the last time I looked into it as soon as you put the wildcard in it just captures everything after that. Also / is the magic character that exits the current capture for params. So, of you wanted to handle the above, you could write it like /api/v1/object/*action, then inside the handler for that path, you could do a path.Base() call to get everything from the end of action to the last /. Then run that through a switch to pass the request into that specific handler.
So path.Base would return presignedurl, and you switch on the return of path.Base, and then execute what you wanted to put in your HandlerFunc in the first place.
Jamie Stackhouse
@itsjamie
Nov 15 2016 07:08
Alternatively, if you wanted to handle the URL splitting you could also just do a strings.Split("/"), and that way if you needed to know test, demo1, etc you could write plenty of custom logic for what essentially becomes a prefix of /api/v1/object
@JackTiger
JackTiger
@JackTiger
Nov 15 2016 09:08
@itsjamie ths
By the way, when I use gin, If to want to send json string to response, but the string contains "&, <, >" characters, how should I do?