Documentation ¶
Overview ¶
A simple http server interface to Swarm
Index ¶
- Variables
- func Adapt(h http.Handler, adapters ...Adapter) http.Handler
- func GetRUID(ctx context.Context) string
- func GetURI(ctx context.Context) *api.URI
- func InitLoggingResponseWriter(h http.Handler) http.Handler
- func InstrumentOpenTracing(h http.Handler) http.Handler
- func ParseURI(h http.Handler) http.Handler
- func RecoverPanic(h http.Handler) http.Handler
- func RespondError(w http.ResponseWriter, r *http.Request, msg string, code int)
- func RespondTemplate(w http.ResponseWriter, r *http.Request, templateName, msg string, code int)
- func SetRUID(ctx context.Context, ruid string) context.Context
- func SetRequestHost(h http.Handler) http.Handler
- func SetRequestID(h http.Handler) http.Handler
- func SetURI(ctx context.Context, uri *api.URI) context.Context
- func ShowMultipleChoices(w http.ResponseWriter, r *http.Request, list api.ManifestList)
- type Adapter
- type ResponseParams
- type RoundTripper
- type Server
- func (s *Server) HandleBzzGet(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleDelete(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleGetFile(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleGetList(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleGetResource(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandlePostFiles(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandlePostRaw(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandlePostResource(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleRootPaths(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListenAndServe(addr string) error
Constants ¶
This section is empty.
Variables ¶
var TemplatesMap = make(map[string]*template.Template)
Functions ¶
func Adapt ¶
Adapt chains h (main request handler) main handler to adapters (middleware handlers) Please note that the order of execution for `adapters` is FIFO (adapters[0] will be executed first)
func RespondError ¶
func RespondTemplate ¶
func ShowMultipleChoices ¶
func ShowMultipleChoices(w http.ResponseWriter, r *http.Request, list api.ManifestList)
ShowMultipleChoices is used when a user requests a resource in a manifest which results in ambiguous results. It returns a HTML page with clickable links of each of the entry in the manifest which fits the request URI ambiguity. For example, if the user requests bzz:/<hash>/read and that manifest contains entries "readme.md" and "readinglist.txt", a HTML page is returned with this two links. This only applies if the manifest has no default entry
Types ¶
type ResponseParams ¶
type RoundTripper ¶
type Server ¶
browser API for registering bzz url scheme handlers: https://developer.mozilla.org/en/docs/Web-based_protocol_handlers electron (chromium) api for registering bzz url scheme handlers: https://github.com/atom/electron/blob/master/docs/api/protocol.md
func (*Server) HandleBzzGet ¶
func (s *Server) HandleBzzGet(w http.ResponseWriter, r *http.Request)
func (*Server) HandleDelete ¶
func (s *Server) HandleDelete(w http.ResponseWriter, r *http.Request)
HandleDelete handles a DELETE request to bzz:/<manifest>/<path>, removes <path> from <manifest> and returns the resulting manifest hash as a text/plain response
func (*Server) HandleGet ¶
func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request)
HandleGet handles a GET request to
- bzz-raw://<key> and responds with the raw content stored at the given storage key
- bzz-hash://<key> and responds with the hash of the content stored at the given storage key as a text/plain response
func (*Server) HandleGetFile ¶
func (s *Server) HandleGetFile(w http.ResponseWriter, r *http.Request)
HandleGetFile handles a GET request to bzz://<manifest>/<path> and responds with the content of the file at <path> from the given <manifest>
func (*Server) HandleGetList ¶
func (s *Server) HandleGetList(w http.ResponseWriter, r *http.Request)
HandleGetList handles a GET request to bzz-list:/<manifest>/<path> and returns a list of all files contained in <manifest> under <path> grouped into common prefixes using "/" as a delimiter
func (*Server) HandleGetResource ¶
func (s *Server) HandleGetResource(w http.ResponseWriter, r *http.Request)
Retrieve mutable resource updates: bzz-resource://<id> - get latest update bzz-resource://<id>/<n> - get latest update on period n bzz-resource://<id>/<n>/<m> - get update version m of period n bzz-resource://<id>/meta - get metadata and next version information <id> = ens name or hash TODO: Enable pass maxPeriod parameter
func (*Server) HandlePostFiles ¶
func (s *Server) HandlePostFiles(w http.ResponseWriter, r *http.Request)
HandlePostFiles handles a POST request to bzz:/<hash>/<path> which contains either a single file or multiple files (either a tar archive or multipart form), adds those files either to an existing manifest or to a new manifest under <path> and returns the resulting manifest hash as a text/plain response
func (*Server) HandlePostRaw ¶
func (s *Server) HandlePostRaw(w http.ResponseWriter, r *http.Request)
HandlePostRaw handles a POST request to a raw bzz-raw:/ URI, stores the request body in swarm and returns the resulting storage address as a text/plain response
func (*Server) HandlePostResource ¶
func (s *Server) HandlePostResource(w http.ResponseWriter, r *http.Request)
Handles creation of new mutable resources and adding updates to existing mutable resources There are two types of updates available, "raw" and "multihash." If the latter is used, a subsequent bzz:// GET call to the manifest of the resource will return the page that the multihash is pointing to, as if it held a normal swarm content manifest
The POST request admits a JSON structure as defined in the mru package: `mru.updateRequestJSON` The requests can be to a) create a resource, b) update a resource or c) both a+b: create a resource and set the initial content
func (*Server) HandleRootPaths ¶
func (s *Server) HandleRootPaths(w http.ResponseWriter, r *http.Request)