@@ -17,8 +17,8 @@ import (
1717
1818var (
1919 errInvalidReq = errors .New ("INVALID REQUEST" )
20- errUnknowAct = errors .New ("Unkown Action " )
21- errUnknowPath = errors .New ("Unkown Path " )
20+ errUnknowAct = errors .New ("UNKOWN ACTION " )
21+ errUnknowPath = errors .New ("UNKOWN PATH " )
2222)
2323
2424func (s * Server ) apiGET (w http.ResponseWriter , r * http.Request ) error {
@@ -95,29 +95,29 @@ func (s *Server) apiPOST(r *http.Request) error {
9595
9696 action := strings .TrimPrefix (r .URL .Path , "/api/" )
9797 if r .Method != "POST" {
98- return fmt .Errorf ("Invalid request method (expecting POST)" )
98+ return fmt .Errorf ("ERROR: Invalid request method (expecting POST)" )
9999 }
100100
101101 data , err := ioutil .ReadAll (r .Body )
102102 if err != nil {
103- return fmt .Errorf ("Failed to download request body: %w" , err )
103+ return fmt .Errorf ("ERROR: Failed to download request body: %w" , err )
104104 }
105105
106106 //convert url into torrent bytes
107107 if action == "url" {
108108 url := string (data )
109109 remote , err := http .Get (url )
110110 if err != nil {
111- return fmt .Errorf ("Invalid remote torrent URL: %s %w" , url , err )
111+ return fmt .Errorf ("ERROR: Invalid remote torrent URL: %s %w" , url , err )
112112 }
113113 defer remote .Body .Close ()
114114 if remote .ContentLength > 512 * 1024 {
115115 //enforce max body size (512k)
116- return fmt .Errorf ("Remote torrent too large" )
116+ return fmt .Errorf ("ERROR: Remote torrent too large" )
117117 }
118118 data , err = ioutil .ReadAll (remote .Body )
119119 if err != nil {
120- return fmt .Errorf ("Failed to download remote torrent: %w" , err )
120+ return fmt .Errorf ("ERROR: Failed to download remote torrent: %w" , err )
121121 }
122122 action = "torrentfile"
123123 }
@@ -144,7 +144,7 @@ func (s *Server) apiPOST(r *http.Request) error {
144144 if errors .Is (err , engine .ErrMaxConnTasks ) {
145145 return nil
146146 }
147- return fmt .Errorf ("Magnet error: %w" , err )
147+ return fmt .Errorf ("ERROR: Magnet error: %w" , err )
148148 }
149149 case "torrent" :
150150 cmd := strings .SplitN (string (data ), ":" , 2 )
@@ -173,7 +173,7 @@ func (s *Server) apiPOST(r *http.Request) error {
173173 }
174174 s .engine .PushWaitTask (infohash )
175175 default :
176- return fmt .Errorf ("Invalid state: %s" , state )
176+ return fmt .Errorf ("ERROR: Invalid state: %s" , state )
177177 }
178178 case "file" :
179179 cmd := strings .SplitN (string (data ), ":" , 3 )
@@ -193,10 +193,10 @@ func (s *Server) apiPOST(r *http.Request) error {
193193 return err
194194 }
195195 default :
196- return fmt .Errorf ("Invalid state: %s" , state )
196+ return fmt .Errorf ("ERROR: Invalid state: %s" , state )
197197 }
198198 default :
199- return fmt .Errorf ("Invalid action: %s" , action )
199+ return fmt .Errorf ("ERROR: Invalid action: %s" , action )
200200 }
201201 return nil
202202}
@@ -220,7 +220,7 @@ func (s *Server) apiConfigure(data []byte) error {
220220
221221 if status & engine .ForbidRuntimeChange > 0 {
222222 log .Printf ("[api] warnning! someone tried to change DoneCmd config" )
223- return errors .New ("Nice Try! But this is NOT allowed being changed on runtime" )
223+ return errors .New ("ERROR: This item is NOT allowed being changed on runtime" )
224224 }
225225 if status & engine .NeedRestartWatch > 0 {
226226 s .engine .StartTorrentWatcher ()
0 commit comments