net

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Overview

This package contains helper functions for that are related to API calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, password string) string

It takes a username and password, concatenates them with a colon, encodes the resulting string in base64, and returns the encoded string - username: the username - password: the password - returns: the encoded string

func CallApi

func CallApi(url string, method string, headers []Header, payload io.Reader, ignore_ssl bool) ([]byte, bool, error)

CallApi() is a function that takes a URL, a method, a list of headers, a payload, and a boolean to ignore SSL errors. It returns a byte array of result data, a boolean, and an error - url: the URL to call - method: the HTTP method to use POST GET PATH etc - headers: a list of headers to send with the request - payload: the data to send with the request - ignore_ssl: a boolean to ignore SSL errors - returns: a byte array of result data, a boolean is success, and an error if there is one

func CheckValidUrl

func CheckValidUrl(host string) error

CheckValidUrl Check If the host string contains either "http://" or "https://", return nil. Otherwise, return an error - host: the host string to check - returns: an error if the host string does not contain either "http://" or "https://"

func RemoveURL

func RemoveURL(str string) string

RemoveURL removes http:// or https:// from a string - str: the string to remove http:// or https:// from - returns: the string without http:// or https://

Types

type Header struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

Header struct for api headers

Jump to

Keyboard shortcuts

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