PanelLibrary: Adds get and getAll to the api (#29772)

* PanelLibrary: Adds get to the API

* Refactor: adds tests for get and getAll and cleans up other tests

* Refactor: changed name on DTO

* Update pkg/services/librarypanels/api.go

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update pkg/services/librarypanels/database.go
This commit is contained in:
Hugo Häggmark
2020-12-21 09:40:27 +01:00
committed by GitHub
parent e598c9e6d9
commit 433b861093
5 changed files with 306 additions and 103 deletions

View File

@@ -19,6 +19,8 @@ type Response interface {
WriteTo(ctx *models.ReqContext)
// Status gets the response's status.
Status() int
// Body gets the response's body.
Body() []byte
}
type NormalResponse struct {
@@ -48,6 +50,11 @@ func (r *NormalResponse) Status() int {
return r.status
}
// Body gets the response's body.
func (r *NormalResponse) Body() []byte {
return r.body
}
func (r *NormalResponse) WriteTo(ctx *models.ReqContext) {
if r.err != nil {
ctx.Logger.Error(r.errMessage, "error", r.err, "remote_addr", ctx.RemoteAddr())