mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-11 11:08:11 -07:00
Simpler interface
This commit is contained in:
+5
-30
@@ -102,16 +102,11 @@ func (t *Tracker) delTorrent(w http.ResponseWriter, r *http.Request, p httproute
|
||||
}
|
||||
|
||||
func (t *Tracker) getUser(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||
base, err := t.pool.Get()
|
||||
conn, err := t.pool.Get()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
conn, private := base.(tracker.PrivateConn)
|
||||
if !private {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
user, err := conn.FindUser(p.ByName("passkey"))
|
||||
if err == tracker.ErrUserDNE {
|
||||
return http.StatusNotFound, err
|
||||
@@ -141,16 +136,11 @@ func (t *Tracker) putUser(w http.ResponseWriter, r *http.Request, p httprouter.P
|
||||
return http.StatusBadRequest, err
|
||||
}
|
||||
|
||||
base, err := t.pool.Get()
|
||||
conn, err := t.pool.Get()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
conn, private := base.(tracker.PrivateConn)
|
||||
if !private {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
err = conn.PutUser(&user)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
@@ -160,16 +150,11 @@ func (t *Tracker) putUser(w http.ResponseWriter, r *http.Request, p httprouter.P
|
||||
}
|
||||
|
||||
func (t *Tracker) delUser(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||
base, err := t.pool.Get()
|
||||
conn, err := t.pool.Get()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
conn, private := base.(tracker.PrivateConn)
|
||||
if !private {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
err = conn.DeleteUser(p.ByName("passkey"))
|
||||
if err == tracker.ErrUserDNE {
|
||||
return http.StatusNotFound, err
|
||||
@@ -181,16 +166,11 @@ func (t *Tracker) delUser(w http.ResponseWriter, r *http.Request, p httprouter.P
|
||||
}
|
||||
|
||||
func (t *Tracker) putClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||
base, err := t.pool.Get()
|
||||
conn, err := t.pool.Get()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
conn, private := base.(tracker.PrivateConn)
|
||||
if !private {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
err = conn.PutClient(p.ByName("clientID"))
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
@@ -200,16 +180,11 @@ func (t *Tracker) putClient(w http.ResponseWriter, r *http.Request, p httprouter
|
||||
}
|
||||
|
||||
func (t *Tracker) delClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||
base, err := t.pool.Get()
|
||||
conn, err := t.pool.Get()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
conn, private := base.(tracker.PrivateConn)
|
||||
if !private {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
err = conn.DeleteClient(p.ByName("clientID"))
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
|
||||
Reference in New Issue
Block a user