web

package
v4.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: GPL-3.0 Imports: 5 Imported by: 3

Documentation

Overview

Package web is the service to serve the Prysm web UI. See https://github.com/prysmaticlabs/prysm-web-ui

Index

Constants

This section is empty.

Variables

View Source
var Handler = func(res http.ResponseWriter, req *http.Request) {
	addSecurityHeaders(res)
	u, err := url.ParseRequestURI(req.RequestURI)
	if err != nil {
		log.WithError(err).Error("Cannot parse request URI")
		return
	}
	p := u.Path
	if p == "/" {
		p = "/index.html"
	}
	p = path.Join(prefix, p)

	if d, ok := site[p]; ok {
		m := mime.TypeByExtension(path.Ext(p))
		res.Header().Add("Content-Type", m)
		res.WriteHeader(200)
		if _, err := res.Write(d); err != nil {
			log.WithError(err).Error("Failed to write http response")
		}
	} else if d, ok := site[path.Join(prefix, "index.html")]; ok {

		m := mime.TypeByExtension(".html")
		res.Header().Add("Content-Type", m)
		res.WriteHeader(200)
		if _, err := res.Write(d); err != nil {
			log.WithError(err).Error("Failed to write http response")
		}
	} else {
		log.WithField("URI", req.RequestURI).Error("Path not found")
		res.WriteHeader(404)
		if _, err := res.Write([]byte("Not found")); err != nil {
			log.WithError(err).Error("Failed to write http response")
		}
	}
}

Handler serves web requests from the bundled site data. DEPRECATED: Prysm Web UI and associated endpoints will be fully removed in a future hard fork.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL