Documentation ¶
Index ¶
- Variables
- func UserFromReq(req *http.Request, logger *logrus.Logger) (*database.User, error)
- func WriteError(w http.ResponseWriter, err error, code int)
- type API
- type BlockPOST
- type BlockResponse
- type BlockWithPoWGET
- type BlockWithPoWPOST
- type BlockedHash
- type BlocklistGET
- type DaemonReadyResponse
- type InvalidInput
- type Reporter
- type SkydClient
Constants ¶
This section is empty.
Variables ¶
var ( // AccountsHost is the host on which the accounts service is listening. // NOTE: this variable is overwritten with what is set in the environment AccountsHost = "accounts" // AccountsPort is the port on which the accounts service is listening. // NOTE: this variable is overwritten with what is set in the environment AccountsPort = "3000" )
Functions ¶
func UserFromReq ¶
UserFromReq identifies the user making the request by reading the attached skynet cookie and querying Accounts service for the user's info.
func WriteError ¶ added in v0.1.1
func WriteError(w http.ResponseWriter, err error, code int)
WriteError wraps WriteError from the skyd node api
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is our central entry point to all subsystems relevant to serving requests.
func (*API) ListenAndServe ¶
ListenAndServe starts the API server on the given port.
type BlockPOST ¶
type BlockPOST struct { Skylink skylink `json:"skylink"` Reporter Reporter `json:"reporter"` Tags []string `json:"tags"` // Hash represents the hash of the Skylink's merkle root. Either 'hash' // or 'skylink' must be set. If both are set the Skylink's hash value // must correspond with the hash. // // It is encouraged to use this field when possible as it allows // services that interact with the blocker to only deal with hashes // instead of skylinks. Hash crypto.Hash `json:"hash"` }
BlockPOST describes a request to the /block endpoint.
type BlockResponse ¶
type BlockResponse struct {
Invalids []InvalidInput `json:"invalids"`
}
BlockResponse is the response object returned by the Skyd API's block endpoint
func (*BlockResponse) InvalidHashes ¶
func (br *BlockResponse) InvalidHashes() ([]database.Hash, error)
InvalidHashes is a helper method that converts the list of invalid inputs to an array of hashes.
type BlockWithPoWGET ¶
type BlockWithPoWGET struct {
Target string `json:"target"`
}
BlockWithPoWGET is the response a user gets from the /blockpow endpoint.
type BlockWithPoWPOST ¶
BlockWithPoWPOST describes a request to the /blockpow endpoint containing a pow.
type BlockedHash ¶
BlockedHash describes a blocked hash along with the set of tags it was reported with
type BlocklistGET ¶
type BlocklistGET struct { Entries []BlockedHash `json:"entries"` HasMore bool `json:"hasmore"` }
BlocklistGET returns a list of blocked hashes
type DaemonReadyResponse ¶
type DaemonReadyResponse struct { Ready bool `json:"ready"` Consensus bool `json:"consensus"` Gateway bool `json:"gateway"` Renter bool `json:"renter"` }
DaemonReadyResponse is the response object returned by the Skyd API's ready endpoint
type InvalidInput ¶
InvalidInput is a struct that wraps the invalid input along with an error string indicating why it was deemed invalid
type Reporter ¶
type Reporter struct { Name string `json:"name"` Email string `json:"email"` OtherContact string `json:"othercontact"` }
Reporter is a person who reported that a given skylink should be blocked.
type SkydClient ¶
type SkydClient struct {
// contains filtered or unexported fields
}
SkydClient is a helper struct that gets initialised using a portal url. It exposes API methods and abstracts the response handling.
func NewCustomSkydClient ¶
func NewCustomSkydClient(portalURL string, headers http.Header) *SkydClient
NewCustomSkydClient returns a new SkydClient instance for given portal url and lets you pass a set of headers that will be set on every request.
func NewSkydClient ¶
func NewSkydClient(portalURL, apiPassword string) *SkydClient
NewSkydClient returns a client that has the default user-agent set.
func (*SkydClient) BlockHashes ¶
BlockHashes will perform an API call to skyd to block the given hashes. It returns which hashes were blocked, which hashes were invalid and potentially an error.
func (*SkydClient) BlocklistGET ¶
func (c *SkydClient) BlocklistGET(offset int) (*BlocklistGET, error)
BlocklistGET calls the `/portal/blocklist` endpoint with given parameters
func (*SkydClient) DaemonReady ¶
func (c *SkydClient) DaemonReady() bool
DaemonReady connects to the local skyd and checks its status. Returns true only if skyd is fully ready.
func (*SkydClient) ResolveSkylink ¶
func (c *SkydClient) ResolveSkylink(skylink skymodules.Skylink) (skymodules.Skylink, error)
ResolveSkylink will resolve the given skylink.