// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
/*
We use html templates to handle simple but as informative as possible error pages.
To eliminate circular dependency in case of an error, we don't store error pages on swarm.
We can't save the error pages as html files on disk, or when deploying compiled binaries
they won't be found.
For this reason we resort to save the HTML error pages as strings, which then can be
parsed by Go's html/template package
*/
package http
//This returns the HTML for generic errors
func GetGenericErrorPage() string {
page := `
Swarm::HTTP Error Page
Hmmmmm....Swarm was not able to serve your request!
|
Error message:
|
{{.Msg}}
|
Error code:
|
{{.Code}}
|
`
return page
}
//This returns the HTML for a 404 Not Found error
func GetNotFoundErrorPage() string {
page := `
Swarm::404 HTTP Not Found
Unfortunately, the resource you were trying to access could not be found on swarm.
|
|
{{.Msg}}
|
Error code:
|
{{.Code}}
|
`
return page
}
//This returns the HTML for a page listing disambiguation options
//i.e. if user requested bzz://read and the manifest contains "readme.md" and "readinglist.txt",
//this page is returned with a clickable list the existing disambiguation links in the manifest
func GetMultipleChoicesErrorPage() string {
page := `
Swarm::HTTP Disambiguation Page
Your request yields ambiguous results!
|
Your request may refer to:
|
{{ .Details}}
|
Error code:
|
{{.Code}}
|
`
return page
}