Documentation ¶
Overview ¶
Package mlablocatev2 implements m-lab locate services API v2. This API currently only allows you to get servers for ndt7. Use the mlablocate package for all other m-lab tools.
Example (Usage) ¶
package main import ( "context" "fmt" "net/http" "github.com/apex/log" "github.com/ooni/probe-cli/v3/internal/mlablocatev2" ) func main() { clnt := mlablocatev2.NewClient(http.DefaultClient, log.Log, "miniooni/0.1.0-dev") results, err := clnt.QueryNDT7(context.Background()) if err != nil { log.WithError(err).Fatal("clnt.QueryNDT7 failed") } fmt.Printf("%+v\n", results) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRequestFailed indicates that the response is not "200 Ok" ErrRequestFailed = errors.New("mlablocatev2: request failed") // ErrEmptyResponse indicates that no hosts were returned ErrEmptyResponse = errors.New("mlablocatev2: empty response") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // HTTPClient is the MANDATORY http client to use HTTPClient model.HTTPClient // Hostname is the MANDATORY hostname of the mlablocate API. Hostname string // Logger is the MANDATORY logger to use. Logger model.DebugLogger // Scheme is the MANDATORY scheme to use (http or https). Scheme string // UserAgent is the MANDATORY user-agent to use. UserAgent string }
Client is a client for v2 of the locate services. Please use the NewClient factory to construct a new instance of client, otherwise you MUST fill all the fields marked as MANDATORY.
func NewClient ¶
func NewClient(httpClient model.HTTPClient, logger model.DebugLogger, userAgent string) Client
NewClient creates a client for v2 of the locate services.
type NDT7Result ¶
type NDT7Result struct { // Hostname is an informative field containing the hostname // to which you're connected. Because there are access tokens, // you cannot use this field directly. Hostname string // Site is an informative field containing the site // to which the server belongs to. Site string // WSSDownloadURL is the WebSocket URL to be used for // performing a download over HTTPS. Note that the URL // typically includes the required access token. WSSDownloadURL string // WSSUploadURL is like WSSDownloadURL but for the upload. WSSUploadURL string }
NDT7Result is the result of a v2 locate services query for ndt7.
Click to show internal directories.
Click to hide internal directories.