mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
General web browser handler for bzz: protocol. Changes address bar.
This commit is contained in:
parent
1ab5ec387a
commit
4e32d8c392
2 changed files with 17 additions and 1 deletions
15
bzz/bzzup/bzzhandler.html
Normal file
15
bzz/bzzup/bzzhandler.html
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Register Swarm protocol handler</title>
|
||||||
|
<script type="text/javascript">
|
||||||
|
navigator.registerProtocolHandler("bzz",
|
||||||
|
"http://localhost:8500/%s",
|
||||||
|
"Swarm handler");
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Register Swarm protocol handler</h1>
|
||||||
|
<p>This web page will install a web protocol handler for the <code>bzz:</code> protocol.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -20,6 +20,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
protocolMatcher = regexp.MustCompile("^/bzz:")
|
||||||
uriMatcher = regexp.MustCompile("^/raw/[0-9A-Fa-f]{64}(?:/[a-z]+/[-+0-9a-z]+)?$")
|
uriMatcher = regexp.MustCompile("^/raw/[0-9A-Fa-f]{64}(?:/[a-z]+/[-+0-9a-z]+)?$")
|
||||||
manifestMatcher = regexp.MustCompile("^/[0-9A-Fa-f]{64}")
|
manifestMatcher = regexp.MustCompile("^/[0-9A-Fa-f]{64}")
|
||||||
hashMatcher = regexp.MustCompile("^[0-9A-Fa-f]{64}$")
|
hashMatcher = regexp.MustCompile("^[0-9A-Fa-f]{64}$")
|
||||||
|
|
@ -94,7 +95,7 @@ func (self *sequentialReader) ReadAt(target []byte, off int64) (n int, err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func handler(w http.ResponseWriter, r *http.Request, dpa *DPA) {
|
func handler(w http.ResponseWriter, r *http.Request, dpa *DPA) {
|
||||||
uri := r.RequestURI
|
uri := protocolMatcher.ReplaceAllString(r.RequestURI, "")
|
||||||
switch {
|
switch {
|
||||||
case r.Method == "POST":
|
case r.Method == "POST":
|
||||||
if uri == "/raw" {
|
if uri == "/raw" {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue