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 (
"fmt"
"io"
"net/http"
"strings"
"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"
......@@ -15,18 +14,17 @@ import (
core "github.com/jbenet/go-ipfs/core"
)
type objectHandler struct {
type handler struct {
ipfs
}
// Serve starts the http server
func Serve(address ma.Multiaddr, node *core.IpfsNode) error {
r := mux.NewRouter()
objectHandler := &objectHandler{&ipfsHandler{node}}
apiHandler := &apiHandler{}
handler := &handler{&ipfsHandler{node}}
r.HandleFunc("/ipfs/", objectHandler.postHandler).Methods("POST")
r.PathPrefix("/ipfs/").Handler(objectHandler).Methods("GET")
r.HandleFunc("/ipfs/", handler.postHandler).Methods("POST")
r.PathPrefix("/ipfs/").Handler(handler).Methods("GET")
http.Handle("/", r)
......@@ -38,7 +36,7 @@ func Serve(address ma.Multiaddr, node *core.IpfsNode) error {
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:]
nd, err := i.ResolvePath(path)
......@@ -59,7 +57,7 @@ func (i *objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
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)
if err != nil {
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