// Generates user and tries to find campaign by user profile and max price // Responses: // 200 OK - return winner struct as Json object // 400 Bad Request - return error string func SearchAuto(w http.ResponseWriter, req *http.Request) { if req.Method != "GET" { sendString(w, http.StatusNotFound, "Not Found") return } sendJson(w, http.StatusOK, bidding.ProcessBid(user.Generate())) }
// Returns won campaign by user profile and campaign max price // Json array of campaigns should be send in request body (POST) // Responses: // 200 OK - return winner struct as Json object // 400 Bad Request - return error string func Search(w http.ResponseWriter, req *http.Request) { if req.Method != "POST" { sendString(w, http.StatusNotFound, "Not Found") return } u := &user.User{} decoder := json.NewDecoder(req.Body) if decoder.Decode(u) != nil { sendString(w, http.StatusBadRequest, "Bad Request") return } sendJson(w, http.StatusOK, bidding.ProcessBid(u)) }