http

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2018 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

A simple http server interface to Swarm

Index

Constants

This section is empty.

Variables

View Source
var TemplatesMap = make(map[string]*template.Template)

Functions

func Adapt added in v1.8.14

func Adapt(h http.Handler, adapters ...Adapter) http.Handler

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 GetRUID added in v1.8.14

func GetRUID(ctx context.Context) string

func GetURI added in v1.8.14

func GetURI(ctx context.Context) *api.URI

func InitLoggingResponseWriter added in v1.8.14

func InitLoggingResponseWriter(h http.Handler) http.Handler

func InstrumentOpenTracing added in v1.8.14

func InstrumentOpenTracing(h http.Handler) http.Handler

func ParseURI added in v1.8.14

func ParseURI(h http.Handler) http.Handler

func RecoverPanic added in v1.8.14

func RecoverPanic(h http.Handler) http.Handler

func RespondError added in v1.8.14

func RespondError(w http.ResponseWriter, r *http.Request, msg string, code int)

func RespondTemplate added in v1.8.14

func RespondTemplate(w http.ResponseWriter, r *http.Request, templateName, msg string, code int)

func SetRUID added in v1.8.14

func SetRUID(ctx context.Context, ruid string) context.Context

func SetRequestHost added in v1.8.14

func SetRequestHost(h http.Handler) http.Handler

func SetRequestID added in v1.8.14

func SetRequestID(h http.Handler) http.Handler

func SetURI added in v1.8.14

func SetURI(ctx context.Context, uri *api.URI) context.Context

func ShowMultipleChoices added in v1.7.2

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 Adapter added in v1.8.14

type Adapter func(http.Handler) http.Handler

type ResponseParams added in v1.8.12

type ResponseParams struct {
	Msg       template.HTML
	Code      int
	Timestamp string

	Details template.HTML
	// contains filtered or unexported fields
}

type RoundTripper

type RoundTripper struct {
	Host string
	Port string
}

func (*RoundTripper) RoundTrip

func (self *RoundTripper) RoundTrip(req *http.Request) (resp *http.Response, err error)

type Server added in v1.5.6

type Server struct {
	http.Handler
	// contains filtered or unexported fields
}

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 NewServer added in v1.6.0

func NewServer(api *api.API, corsString string) *Server

func (*Server) HandleBzzGet added in v1.8.14

func (s *Server) HandleBzzGet(w http.ResponseWriter, r *http.Request)

func (*Server) HandleDelete added in v1.6.0

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 added in v1.8.0

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) HandleGetFeed

func (s *Server) HandleGetFeed(w http.ResponseWriter, r *http.Request)

HandleGetFeed retrieves Swarm feeds updates: bzz-feed://<manifest address or ENS name> - get latest feed update, given a manifest address - or - specify user + topic (optional), subtopic name (optional) directly, without manifest: bzz-feed://?user=0x...&topic=0x...&name=subtopic name topic defaults to 0x000... if not specified. name defaults to empty string if not specified. thus, empty name and topic refers to the user's default feed.

Optional parameters: time=xx - get the latest update before time (in epoch seconds) hint.time=xx - hint the lookup algorithm looking for updates at around that time hint.level=xx - hint the lookup algorithm looking for updates at around this frequency level meta=1 - get feed metadata and status information instead of performing a feed query NOTE: meta=1 will be deprecated in the near future

func (*Server) HandleGetFile added in v1.6.0

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 added in v1.6.0

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) HandlePostFeed

func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request)

Handles feed manifest creation and feed updates The POST request admits a JSON structure as defined in the feeds package: `feed.updateRequestJSON` The requests can be to a) create a feed manifest, b) update a feed or c) both a+b: create a feed manifest and publish a first update

func (*Server) HandlePostFiles added in v1.6.0

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 added in v1.6.0

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) HandleRootPaths added in v1.8.13

func (s *Server) HandleRootPaths(w http.ResponseWriter, r *http.Request)

func (*Server) ListenAndServe added in v1.8.13

func (s *Server) ListenAndServe(addr string) error

Jump to

Keyboard shortcuts

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