|
|
@@ -33,16 +33,20 @@ func boardHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
} |
|
|
|
args := r.URL.Query() |
|
|
|
// check args pre-conditions |
|
|
|
if !(checkArgExists(args, "board", w) || checkArgExists(args, "name", w)) { |
|
|
|
if !(checkArgExists(args, "board", w) || checkArgExists(args, "name", w) || (checkArgExists(args, "id", w) && checkArgInt(args, "id", w, 0))) { |
|
|
|
errorResponse(400, "Missing required 'board' URL parameter", w, r) |
|
|
|
return |
|
|
|
} |
|
|
|
board := "" |
|
|
|
var boardId int = -1 |
|
|
|
if checkArgExists(args, "name", w) { |
|
|
|
board = args.Get("name") |
|
|
|
} |
|
|
|
if checkArgExists(args, "board", w) { |
|
|
|
board = args.Get("board") |
|
|
|
} |
|
|
|
if checkArgExists(args, "id", w) { |
|
|
|
boardId, _ = strconv.Atoi(args.Get("id")) |
|
|
|
} |
|
|
|
if !checkArgExists(args, "count", w) || !checkArgInt(args, "count", w, 0) { |
|
|
|
//w.WriteHeader(400) |
|
|
@@ -58,7 +62,14 @@ func boardHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
start, _ := strconv.Atoi(args.Get("start")) |
|
|
|
// execute query |
|
|
|
result := NewResult("", r.URL.String()) |
|
|
|
b, err := boardByName(board) |
|
|
|
var b *Board |
|
|
|
var err error |
|
|
|
if (boardId == -1) { |
|
|
|
b, err = boardByName(board) |
|
|
|
} else { |
|
|
|
b, err = boardById(int64(boardId)) |
|
|
|
} |
|
|
|
|
|
|
|
//b, ok := boards[board] |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|