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(
|
||||
ctx.Method(),
|
||||
string(ctx.Method()),
|
||||
fmt.Sprintf(
|
||||
"%s://%s:%s%s",
|
||||
scheme,
|
||||
|
@ -72,9 +72,13 @@ func handler(ctx *fasthttp.RequestCtx) {
|
|||
var code int
|
||||
|
||||
err := row.Scan(&id, &code)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
ctx.Response.SetStatusCode(404)
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.Response.SetStatusCode(500)
|
||||
ctx.Response.SetBodyString("Unable to fetch row: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// -- set status code
|
||||
|
|
Loading…
Add table
Reference in a new issue