rm last printf in http
This commit is contained in:
parent
292c15e519
commit
8ddbf32002
1 changed files with 6 additions and 3 deletions
|
@ -5,7 +5,6 @@
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -13,6 +12,7 @@ import (
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
"github.com/stretchr/graceful"
|
"github.com/stretchr/graceful"
|
||||||
|
|
||||||
|
"github.com/chihaya/bencode"
|
||||||
"github.com/chihaya/chihaya/config"
|
"github.com/chihaya/chihaya/config"
|
||||||
"github.com/chihaya/chihaya/drivers/backend"
|
"github.com/chihaya/chihaya/drivers/backend"
|
||||||
"github.com/chihaya/chihaya/drivers/tracker"
|
"github.com/chihaya/chihaya/drivers/tracker"
|
||||||
|
@ -97,6 +97,9 @@ func Serve(cfg *config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fail(w http.ResponseWriter, r *http.Request, err error) {
|
func fail(w http.ResponseWriter, r *http.Request, err error) {
|
||||||
errmsg := err.Error()
|
dict := bencode.NewDict()
|
||||||
fmt.Fprintf(w, "d14:failure reason%d:%se", len(errmsg), errmsg)
|
dict["failure reason"] = err.Error()
|
||||||
|
|
||||||
|
bencoder := bencode.NewEncoder(w)
|
||||||
|
bencoder.Encode(dict)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue