Adding initial scaffolding to rename the repository
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
c7472582a7
commit
0f880ac1fa
46 changed files with 5707 additions and 674 deletions
35
internal/api/errors.go
Normal file
35
internal/api/errors.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/photoprism/photoprism/internal/acl"
|
||||
"github.com/photoprism/photoprism/internal/query"
|
||||
"github.com/photoprism/photoprism/pkg/txt"
|
||||
)
|
||||
|
||||
func GetErrors(router *gin.RouterGroup) {
|
||||
router.GET("/errors", func(c *gin.Context) {
|
||||
s := Auth(SessionID(c), acl.ResourceLogs, acl.ActionSearch)
|
||||
|
||||
if s.Invalid() {
|
||||
AbortUnauthorized(c)
|
||||
return
|
||||
}
|
||||
|
||||
limit := txt.Int(c.Query("count"))
|
||||
offset := txt.Int(c.Query("offset"))
|
||||
|
||||
if resp, err := query.Errors(limit, offset, c.Query("q")); err != nil {
|
||||
c.AbortWithStatusJSON(400, gin.H{"error": txt.UcFirst(err.Error())})
|
||||
return
|
||||
} else {
|
||||
AddCountHeader(c, len(resp))
|
||||
AddLimitHeader(c, limit)
|
||||
AddOffsetHeader(c, offset)
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue