mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
swarm: now able to serve landing page template
This commit is contained in:
parent
a5fe5cc138
commit
87f5fd1daf
2 changed files with 141 additions and 1 deletions
|
|
@ -609,6 +609,15 @@ func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
|
||||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
s.logDebug("HTTP %s request URL: '%s', Host: '%s', Path: '%s', Referer: '%s', Accept: '%s'", r.Method, r.RequestURI, r.URL.Host, r.URL.Path, r.Referer(), r.Header.Get("Accept"))
|
s.logDebug("HTTP %s request URL: '%s', Host: '%s', Path: '%s', Referer: '%s', Accept: '%s'", r.Method, r.RequestURI, r.URL.Host, r.URL.Path, r.Referer(), r.Header.Get("Accept"))
|
||||||
|
|
||||||
|
if r.RequestURI == "/" && strings.Contains(r.Header.Get("Accept"), "text/html") {
|
||||||
|
|
||||||
|
err := landingPageTemplate.Execute(w, nil)
|
||||||
|
if err != nil {
|
||||||
|
s.logError("error rendering landing page: %s", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
uri, err := api.Parse(strings.TrimLeft(r.URL.Path, "/"))
|
uri, err := api.Parse(strings.TrimLeft(r.URL.Path, "/"))
|
||||||
req := &Request{Request: *r, uri: uri}
|
req := &Request{Request: *r, uri: uri}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -662,6 +671,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s.HandleGetFile(w, req)
|
s.HandleGetFile(w, req)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue