Skip to content

Commit

Permalink
feat(controller): add admin list/search endpoint controller
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Oct 3, 2020
1 parent 29e29d7 commit ff7987d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions controller/admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package controller

import (
"net/http"

"github.com/adhocore/urlsh/response"
"github.com/adhocore/urlsh/service/url"
)

func ListUrl(res http.ResponseWriter, req *http.Request) {
urls, err := url.ListUrlsFilteredFromRequest(req)

if err != nil {
response.JSON(res, http.StatusNotFound, response.Body{"message": err.Error(), "urls": urls})
return
}

response.JSON(res, http.StatusOK, response.Body{"urls": urls})
}

0 comments on commit ff7987d

Please sign in to comment.