aboutsummaryrefslogtreecommitdiff
path: root/service/transport.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-01-30 15:32:37 +0000
committerr <r@freesoftwareextremist.com>2020-01-30 15:37:07 +0000
commit17e55d2a9bc7d0f5ed922370b8ac3ad4db9f583b (patch)
tree37f94e17e31d7485d16b6d9922023ffb182a5e6d /service/transport.go
parent84cd3bc4368afdfe41320b1388fd9a14bf90fce9 (diff)
downloadbloat-17e55d2a9bc7d0f5ed922370b8ac3ad4db9f583b.tar.gz
bloat-17e55d2a9bc7d0f5ed922370b8ac3ad4db9f583b.zip
Add user search page
Diffstat (limited to 'service/transport.go')
-rw-r--r--service/transport.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/service/transport.go b/service/transport.go
index fbab2e5..8f6c547 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -188,6 +188,30 @@ func NewHandler(s Service, staticDir string) http.Handler {
}
}
+ userSearchPage := func(w http.ResponseWriter, req *http.Request) {
+ c := newClient(w)
+ ctx := newCtxWithSesion(req)
+ id, _ := mux.Vars(req)["id"]
+ q := req.URL.Query().Get("q")
+ offsetStr := req.URL.Query().Get("offset")
+
+ var offset int
+ var err error
+ if len(offsetStr) > 1 {
+ offset, err = strconv.Atoi(offsetStr)
+ if err != nil {
+ s.ServeErrorPage(ctx, c, err)
+ return
+ }
+ }
+
+ err = s.ServeUserSearchPage(ctx, c, id, q, offset)
+ if err != nil {
+ s.ServeErrorPage(ctx, c, err)
+ return
+ }
+ }
+
aboutPage := func(w http.ResponseWriter, req *http.Request) {
c := newClient(w)
ctx := newCtxWithSesion(req)
@@ -545,6 +569,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
r.HandleFunc("/followers/{id}", followersPage).Methods(http.MethodGet)
r.HandleFunc("/notifications", notificationsPage).Methods(http.MethodGet)
r.HandleFunc("/user/{id}", userPage).Methods(http.MethodGet)
+ r.HandleFunc("/usersearch/{id}", userSearchPage).Methods(http.MethodGet)
r.HandleFunc("/about", aboutPage).Methods(http.MethodGet)
r.HandleFunc("/emojis", emojisPage).Methods(http.MethodGet)
r.HandleFunc("/search", searchPage).Methods(http.MethodGet)