Documentation ¶
Index ¶
- Constants
- func DownloadFile(url string, filepath string) error
- func DownloadFileWithGrab(url string, filepath string, updateIntervalMillis int, ...) error
- func JSONRequest(httpClient *http.Client, method string, reqURL string, data string, ...) error
- func JSONRequestDynamicHeaders(httpClient *http.Client, method string, reqURL string, data string, ...) error
- func ParseBool(m map[string]interface{}, key string, methodAPI string) (bool, error)
- func ParseNumber(m map[string]interface{}, key string, methodAPI string) (*model.Number, error)
- func ParseString(m map[string]interface{}, key string, methodAPI string) (string, error)
- type AuthLevel
- type Config
- type Endpoint
- type HeaderFn
- type HeaderFnFactory
- type WebServer
Constants ¶
const PrefixFieldNotFound = "could not find field in map"
PrefixFieldNotFound is what is returned in the error when we cannot find a field in the map
Variables ¶
This section is empty.
Functions ¶
func DownloadFile ¶ added in v1.8.0
DownloadFile downloads a URL to a file on the local disk as it downloads it.
func DownloadFileWithGrab ¶ added in v1.9.0
func DownloadFileWithGrab( url string, filepath string, updateIntervalMillis int, statusCodeHandler func(statusCode int, statusString string), updateHandler func(completedMB float64, sizeMB float64, speedMBPerSec float64), finishHandler func(filename string), ) error
DownloadFileWithGrab is a download function that uses the grab third-party library
func JSONRequest ¶
func JSONRequest( httpClient *http.Client, method string, reqURL string, data string, headers map[string]string, responseData interface{}, errorKey string, ) error
JSONRequest submits an HTTP web request and parses the response into the responseData object as JSON
func JSONRequestDynamicHeaders ¶ added in v1.8.0
func JSONRequestDynamicHeaders( httpClient *http.Client, method string, reqURL string, data string, headers map[string]HeaderFn, responseData interface{}, errorKey string, ) error
JSONRequestDynamicHeaders submits an HTTP web request and parses the response into the responseData object as JSON
func ParseNumber ¶
ParseNumber helps to parse a model.Number value out of the map
Types ¶
type AuthLevel ¶
type AuthLevel int
AuthLevel specifies the level of authentication needed for an endpoint.
type Config ¶
type Config struct { // PermittedEmails is a map of emails that are allowed access to the endpoints protected by Google authentication PermittedEmails map[string]bool // GoogleClientID - client ID of the Google application. It should only be left empty if no endpoints require // Google authentication GoogleClientID string // GoogleClientSecret - client secret of the Google application. It should only be left empty if no endpoints require // Google authentication GoogleClientSecret string }
Config is a struct storing configuration parameters for the monitoring server.
type Endpoint ¶
type Endpoint interface { GetHandlerFunc() http.HandlerFunc GetAuthLevel() AuthLevel GetPath() string }
Endpoint represents an API endpoint that implements GetHandlerFunc which returns a http.HandlerFunc specifying the behavior when this endpoint is hit. It's also required to implement GetAuthLevel, which returns the level of authentication that's required to access this endpoint. Currently, the values can be NoAuth or GoogleAuth. Lastly, GetPath returns the path that routes to this endpoint.
type HeaderFn ¶ added in v1.8.0
type HeaderFn func(string, string, string) string // (string httpMethod, string requestPath, string body)
HeaderFn represents a function that transforms headers
func MakeHeaderFn ¶ added in v1.8.0
func MakeHeaderFn(value string, primaryMappings map[string]HeaderFnFactory) (HeaderFn, error)
MakeHeaderFn is a factory method that makes a HeaderFn
type HeaderFnFactory ¶ added in v1.8.0
HeaderFnFactory is a factory method for the HeaderFn