go-json-rest icon indicating copy to clipboard operation
go-json-rest copied to clipboard

float in get params

Open kunkhmer opened this issue 7 years ago • 2 comments

Im having a problem passing a float in .GET with params. Is there any solution for this problem? Any double will return "resource not found"

kunkhmer avatar Apr 07 '17 23:04 kunkhmer

I just ended up using .Post

kunkhmer avatar Apr 13 '17 02:04 kunkhmer

The documentation isn't very clear on how to get query parameters, but see #104

I succeed to get a float from query parameter:

func GetRecord(w rest.ResponseWriter, req *rest.Request) {
	if req.URL.Query().Get("startDate") != "" {
		if startDate, err := strconv.ParseFloat(req.URL.Query().Get("startDate"), 64); err == nil && startDate > 0 {
			// do somethings
		} else if err != nil {
			// do somethings
		}
	}
	// do somethings
}

antitoine avatar Oct 05 '17 08:10 antitoine