swarm/api: rename bzzh URL scheme to bzz-hash

This commit is contained in:
Janos Guljas 2017-12-13 12:02:15 +01:00
parent 379040e22d
commit 75c8a1835d
4 changed files with 11 additions and 11 deletions

View file

@ -293,7 +293,7 @@ func (s *Server) HandleDelete(w http.ResponseWriter, r *Request) {
// HandleGet handles a GET request to // HandleGet handles a GET request to
// - bzzr://<key> and responds with the raw content stored at the // - bzzr://<key> and responds with the raw content stored at the
// given storage key // given storage key
// - bzzh://<key> and responds with the hash of the content stored // - bzz-hash://<key> and responds with the hash of the content stored
// at the given storage key as a text/plain response // at the given storage key as a text/plain response
func (s *Server) HandleGet(w http.ResponseWriter, r *Request) { func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
key, err := s.api.Resolve(r.uri) key, err := s.api.Resolve(r.uri)

View file

@ -108,7 +108,7 @@ func TestBzzGetPath(t *testing.T) {
var resp *http.Response var resp *http.Response
var respbody []byte var respbody []byte
url := srv.URL + "/bzzh:/" url := srv.URL + "/bzz-hash:/"
if k[:] != "" { if k[:] != "" {
url += common.ToHex(key[0])[2:] + "/" + k[1:] url += common.ToHex(key[0])[2:] + "/" + k[1:]
} }
@ -137,7 +137,7 @@ func TestBzzGetPath(t *testing.T) {
srv.URL + "/bzz:/name", srv.URL + "/bzz:/name",
srv.URL + "/bzzi:/nonhash", srv.URL + "/bzzi:/nonhash",
srv.URL + "/bzzr:/nonhash", srv.URL + "/bzzr:/nonhash",
srv.URL + "/bzzh:/nonhash", srv.URL + "/bzz-hash:/nonhash",
} }
nonhashresponses := []string{ nonhashresponses := []string{

View file

@ -30,7 +30,7 @@ type URI struct {
// * bzzr - raw swarm content // * bzzr - raw swarm content
// * bzzi - immutable URI of an entry in a swarm manifest // * bzzi - immutable URI of an entry in a swarm manifest
// (address is not resolved) // (address is not resolved)
// * bzzh - hash of swarm content // * bzz-hash - hash of swarm content
// //
Scheme string Scheme string
@ -52,7 +52,7 @@ type URI struct {
// * <scheme>://<addr> // * <scheme>://<addr>
// * <scheme>://<addr>/<path> // * <scheme>://<addr>/<path>
// //
// with scheme one of bzz, bzzr, bzzi or bzzh // with scheme one of bzz, bzzr, bzzi or bzz-hash
func Parse(rawuri string) (*URI, error) { func Parse(rawuri string) (*URI, error) {
u, err := url.Parse(rawuri) u, err := url.Parse(rawuri)
if err != nil { if err != nil {
@ -62,7 +62,7 @@ func Parse(rawuri string) (*URI, error) {
// check the scheme is valid // check the scheme is valid
switch uri.Scheme { switch uri.Scheme {
case "bzz", "bzzi", "bzzr", "bzzh": case "bzz", "bzzi", "bzzr", "bzz-hash":
default: default:
return nil, fmt.Errorf("unknown scheme %q", u.Scheme) return nil, fmt.Errorf("unknown scheme %q", u.Scheme)
} }
@ -94,7 +94,7 @@ func (u *URI) Immutable() bool {
} }
func (u *URI) Hash() bool { func (u *URI) Hash() bool {
return u.Scheme == "bzzh" return u.Scheme == "bzz-hash"
} }
func (u *URI) String() string { func (u *URI) String() string {

View file

@ -97,13 +97,13 @@ func TestParseURI(t *testing.T) {
expectURI: &URI{Scheme: "bzz", Addr: "abc123", Path: "path/to/entry"}, expectURI: &URI{Scheme: "bzz", Addr: "abc123", Path: "path/to/entry"},
}, },
{ {
uri: "bzzh:", uri: "bzz-hash:",
expectURI: &URI{Scheme: "bzzh"}, expectURI: &URI{Scheme: "bzz-hash"},
expectHash: true, expectHash: true,
}, },
{ {
uri: "bzzh:/", uri: "bzz-hash:/",
expectURI: &URI{Scheme: "bzzh"}, expectURI: &URI{Scheme: "bzz-hash"},
expectHash: true, expectHash: true,
}, },
} }