fix(api): always return JSON response on success (fixes #276)
parent
5542be0418
commit
fc4dc30f74
|
@ -227,8 +227,7 @@ fn remove(conf Config, id string) ! {
|
||||||
|
|
||||||
if id_int != 0 {
|
if id_int != 0 {
|
||||||
c := client.new(conf.address, conf.api_key)
|
c := client.new(conf.address, conf.api_key)
|
||||||
res := c.remove_target(id_int)!
|
c.remove_target(id_int)!
|
||||||
println(res.message)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,9 +244,7 @@ fn patch(conf Config, id string, params map[string]string) ! {
|
||||||
id_int := id.int()
|
id_int := id.int()
|
||||||
if id_int != 0 {
|
if id_int != 0 {
|
||||||
c := client.new(conf.address, conf.api_key)
|
c := client.new(conf.address, conf.api_key)
|
||||||
res := c.patch_target(id_int, params)!
|
c.patch_target(id_int, params)!
|
||||||
|
|
||||||
println(res.message)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn (mut app App) v1_post_target() web.Result {
|
||||||
|
|
||||||
id := app.db.add_target(new_repo)
|
id := app.db.add_target(new_repo)
|
||||||
|
|
||||||
return app.json(http.Status.ok, new_data_response(id))
|
return app.json(.ok, new_data_response(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
// v1_delete_target removes a given target from the server's list.
|
// v1_delete_target removes a given target from the server's list.
|
||||||
|
@ -55,7 +55,7 @@ fn (mut app App) v1_post_target() web.Result {
|
||||||
fn (mut app App) v1_delete_target(id int) web.Result {
|
fn (mut app App) v1_delete_target(id int) web.Result {
|
||||||
app.db.delete_target(id)
|
app.db.delete_target(id)
|
||||||
|
|
||||||
return app.status(.ok)
|
return app.json(.ok, new_response(''))
|
||||||
}
|
}
|
||||||
|
|
||||||
// v1_patch_target updates a target's data with the given query params.
|
// v1_patch_target updates a target's data with the given query params.
|
||||||
|
@ -69,5 +69,7 @@ fn (mut app App) v1_patch_target(id int) web.Result {
|
||||||
app.db.update_target_archs(id, arch_objs)
|
app.db.update_target_archs(id, arch_objs)
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.status(.ok)
|
repo := app.db.get_target(id) or { return app.status(.internal_server_error) }
|
||||||
|
|
||||||
|
return app.json(.ok, new_data_response(repo))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue