mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 16:07:42 +08:00
server/http: Fixed build error
This commit is contained in:

committed by
Juan Batiz-Benet

parent
063cb536df
commit
436462c86a
@ -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)
|
||||
|
Reference in New Issue
Block a user