Commit 436462c8 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

server/http: Fixed build error

parent 063cb536
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"strings"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gorilla/mux" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gorilla/mux"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
...@@ -15,18 +14,17 @@ import ( ...@@ -15,18 +14,17 @@ import (
core "github.com/jbenet/go-ipfs/core" core "github.com/jbenet/go-ipfs/core"
) )
type objectHandler struct { type handler struct {
ipfs ipfs
} }
// Serve starts the http server // Serve starts the http server
func Serve(address ma.Multiaddr, node *core.IpfsNode) error { func Serve(address ma.Multiaddr, node *core.IpfsNode) error {
r := mux.NewRouter() r := mux.NewRouter()
objectHandler := &objectHandler{&ipfsHandler{node}} handler := &handler{&ipfsHandler{node}}
apiHandler := &apiHandler{}
r.HandleFunc("/ipfs/", objectHandler.postHandler).Methods("POST") r.HandleFunc("/ipfs/", handler.postHandler).Methods("POST")
r.PathPrefix("/ipfs/").Handler(objectHandler).Methods("GET") r.PathPrefix("/ipfs/").Handler(handler).Methods("GET")
http.Handle("/", r) http.Handle("/", r)
...@@ -38,7 +36,7 @@ func Serve(address ma.Multiaddr, node *core.IpfsNode) error { ...@@ -38,7 +36,7 @@ func Serve(address ma.Multiaddr, node *core.IpfsNode) error {
return http.ListenAndServe(host, nil) return http.ListenAndServe(host, nil)
} }
func (i *objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (i *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path[5:] path := r.URL.Path[5:]
nd, err := i.ResolvePath(path) nd, err := i.ResolvePath(path)
...@@ -59,7 +57,7 @@ func (i *objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -59,7 +57,7 @@ func (i *objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
io.Copy(w, dr) io.Copy(w, dr)
} }
func (i *objectHandler) postHandler(w http.ResponseWriter, r *http.Request) { func (i *handler) postHandler(w http.ResponseWriter, r *http.Request) {
nd, err := i.NewDagFromReader(r.Body) nd, err := i.NewDagFromReader(r.Body)
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment