Created
July 5, 2014 21:20
-
-
Save joshrendek/3bef6106145985b2365a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sshLoginList(res http.ResponseWriter, req *http.Request) { | |
var logins []SshLogin | |
var resp []byte | |
var per_page int64 = 50 | |
page, err := strconv.ParseInt(req.URL.Query()["page"][0], 10, 64) | |
if err != nil { | |
resp, _ = json.Marshal(struct{ Message string }{"Invalid page parameter"}) | |
} | |
fmt.Println(page) | |
DB.Debug().Model(SshLogin{}).Order("id desc").Limit(per_page).Offset(((page * per_page) - per_page)).Find(&logins) | |
resp, _ = json.Marshal(logins) | |
fmt.Fprintln(res, string(resp)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(/Users/joshrendek/go/src/sshd_honey_web/web.go:66) | |
[2014-07-05 17:18:08] Invalid SQL | |
(/Users/joshrendek/go/src/sshd_honey_web/web.go:66) | |
[2014-07-05 17:18:08] [0.33ms] SELECT * FROM "ssh_logins" WHERE (deleted_at IS NULL OR deleted_at <= '0001-01-02') ORDER BY id desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment