@cryptotaxi247 / kubo / commits / 436462c86

server/http: Fixed build error

Matt Bell committed Oct 27, 2014 at 18:59 UTC 436462c86a930726ac23dcea3a0287cd4a759908
1 file changed +6 -8
server/http/http.go
+6 -8
@@ -5,7 +5,6 @@ import (
5 "fmt"
6 "io"
7 "net/http"
8 - "strings"
8
9 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gorilla/mux"
10 ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
@@ -15,18 +14,17 @@ import (
14 core "github.com/jbenet/go-ipfs/core"
15 )
16
18 -type objectHandler struct {
17 +type handler struct {
18 ipfs
19 }
20
21 // Serve starts the http server
22 func Serve(address ma.Multiaddr, node *core.IpfsNode) error {
23 r := mux.NewRouter()
25 - objectHandler := &objectHandler{&ipfsHandler{node}}
26 - apiHandler := &apiHandler{}
24 + handler := &handler{&ipfsHandler{node}}
25
28 - r.HandleFunc("/ipfs/", objectHandler.postHandler).Methods("POST")
29 - r.PathPrefix("/ipfs/").Handler(objectHandler).Methods("GET")
26 + r.HandleFunc("/ipfs/", handler.postHandler).Methods("POST")
27 + r.PathPrefix("/ipfs/").Handler(handler).Methods("GET")
28
29 http.Handle("/", r)
30
@@ -38,7 +36,7 @@ func Serve(address ma.Multiaddr, node *core.IpfsNode) error {
36 return http.ListenAndServe(host, nil)
37 }
38
41 -func (i *objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
39 +func (i *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
40 path := r.URL.Path[5:]
41
42 nd, err := i.ResolvePath(path)
@@ -59,7 +57,7 @@ func (i *objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
57 io.Copy(w, dr)
58 }
59
62 -func (i *objectHandler) postHandler(w http.ResponseWriter, r *http.Request) {
60 +func (i *handler) postHandler(w http.ResponseWriter, r *http.Request) {
61 nd, err := i.NewDagFromReader(r.Body)
62 if err != nil {
63 w.WriteHeader(http.StatusInternalServerError)