feat: adding target returns id of added entry

This commit is contained in:
Jef Roosens 2022-09-05 10:10:02 +02:00
parent 3e0a2584fa
commit 7b59277931
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 11 additions and 7 deletions

View file

@ -2,7 +2,7 @@ module server
import web
import net.http
import web.response { new_data_response, new_response }
import web.response { new_data_response, new_response, new_full_response }
import db
import models { Target, TargetArch, TargetFilter }
@ -45,9 +45,9 @@ fn (mut app App) v1_post_target() web.Result {
return app.json(http.Status.bad_request, new_response('Invalid kind.'))
}
app.db.add_target(new_repo)
id := app.db.add_target(new_repo)
return app.json(http.Status.ok, new_response('Repo added successfully.'))
return app.json(http.Status.ok, new_data_response(id))
}
// v1_delete_target removes a given target from the server's list.