Compare commits
2 commits
459d10664a
...
27a8c3d1d1
Author | SHA1 | Date | |
---|---|---|---|
27a8c3d1d1 | |||
bc6490187d |
1 changed files with 6 additions and 2 deletions
|
@ -58,7 +58,7 @@ func handler(ctx *fasthttp.RequestCtx) {
|
||||||
)
|
)
|
||||||
|
|
||||||
row := stmt.QueryRow(
|
row := stmt.QueryRow(
|
||||||
ctx.Method(),
|
string(ctx.Method()),
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"%s://%s:%s%s",
|
"%s://%s:%s%s",
|
||||||
scheme,
|
scheme,
|
||||||
|
@ -72,9 +72,13 @@ func handler(ctx *fasthttp.RequestCtx) {
|
||||||
var code int
|
var code int
|
||||||
|
|
||||||
err := row.Scan(&id, &code)
|
err := row.Scan(&id, &code)
|
||||||
if err != nil {
|
if err == sql.ErrNoRows {
|
||||||
ctx.Response.SetStatusCode(404)
|
ctx.Response.SetStatusCode(404)
|
||||||
return
|
return
|
||||||
|
} else if err != nil {
|
||||||
|
ctx.Response.SetStatusCode(500)
|
||||||
|
ctx.Response.SetBodyString("Unable to fetch row: " + err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- set status code
|
// -- set status code
|
||||||
|
|
Loading…
Add table
Reference in a new issue