Documentation
¶
Index ¶
- Variables
- func CREATE_SERVICE_ENDPOINT(api_endpoint string, handler_name GENERIC_API_ENDPOINT_HANDLER)
- func DISABLE_API_DEBUG()
- func ENABLE_API_DEBUG()
- func FIND_URL_key(keyname string, UMAP url.Values, myresult *string) bool
- func FIND_VALUE(KEY string, inputVARS []URL_PARAMS) string
- func GENERATE_JSON_Response(DATASET []interface{}) string
- func GEN_JSON_HEADER(first_element string)
- func GEN_PRETTY_JSON(tmpOBJ interface{}) (string, string)
- func GET_JSON_w_RETRY(URL string, PARAMS ...interface{}) (bool, []byte, string)
- func GET_KEY(KEY string, inputVARS []URL_PARAMS) string
- func GET_VALUE(KEY string, inputVARS []URL_PARAMS) string
- func HAVE_ABORT_ERROR(jstext string, GLOBAL_PREFIX string) bool
- func JSON_DOWNLOAD(API_URL string, PARAMS ...interface{}) (bool, []byte, string, error)
- func MAKE_API_JSON(tmpOBJ interface{}) string
- func MINI_WEB(WEBROOT string, listenPort string, START_MESSAGE string, USE_PROD_MODE bool)
- func MinifyJSON(str string) string
- func OVER_THE_LIMIT(jstext string, GLOBAL_PREFIX string, API_SLEEP int) bool
- func SEND_Response_2_Client(JSON_Response string, ClientResponseWriter *http.ResponseWriter)
- func SHOW_ALL_PARAMS(inputVARS []URL_PARAMS) string
- func Simple_FIND_URL_key(keyname string, UMAP url.Values) (bool, string)
- func Start_LISTENER_SERVICE_Engine(USE_PROD_MODE bool)
- type API_ENDPOINT_DEFINITION
- type API_JSON_OBJ
- type GENERIC_API_ENDPOINT_HANDLER
- type HEADER_OBJ
- type TMP_ERR_OBJ
- type URL_PARAMS
Constants ¶
This section is empty.
Variables ¶
var ABORT_ERRORS = []string{
"Bad link",
}
var ALL_COUNT = 0
var ALL_JSON_RESULTS = ""
var ALL_SERVICE_ENDPOINTS []API_ENDPOINT_DEFINITION
var API_DEBUG_ENABLED = false
var DEFAULT_LISTEN_PORT = "8888" // This is the default "listen" port for all webservices.. if using ports below 1024 you must run as root
var JSON_BOTTOM = `
]
}
`
var JSON_CLEAN_FLAG = false // When set to TRUE, we return "MINIFIED" json (it omits whatever spaces and indents you used get stripped out )
var JSON_DATA_HEADER = `
"data" : [
`
var JSON_TOP = `
{
`
var LIMIT_ERRORS = []string{
"You have run out of API credits",
"deadline exceeded",
}
var MAX_JSON_RETRY_ATTEMPTS = 5
var MAX_JSON_SLEEP_VAL = 10
var RETRY_MAX = 500
var SSL_CERT_PEM_FILE = "" // Full path to wherever this CERT/ pem file is (this is just example: /opt/SSL_CERTS/biolab_COMBINED.pem )
var SSL_ENABLE_FLAG = false // If set to true.. we listen in SSL mode.. meaning we need a PEM file and a KEY specified below
var SSL_KEY_FILE = "" // Full path to wherever the KEY file of this cert is (this is just example: /opt/SSL_CERTS/biolab_ALPHA-SSL.key )
var USE_API_SETUP_DEFAULT_PARAMS = false
Functions ¶
func CREATE_SERVICE_ENDPOINT ¶
func CREATE_SERVICE_ENDPOINT(api_endpoint string, handler_name GENERIC_API_ENDPOINT_HANDLER)
Call this to create a new REST API Endpoint /THISADDY
func DISABLE_API_DEBUG ¶
func DISABLE_API_DEBUG()
func ENABLE_API_DEBUG ¶
func ENABLE_API_DEBUG()
func FIND_URL_key ¶
This is meant to be passed a keymap of url.Values
Returns true and expects a POINTER to hold the value that it finds If keyname is found in the map, its VALUE is returned NOTE: this lets you send URL vars of ANY case
FIND_URL_key_using_POINTER("data", URL_MAP, &result):
func GENERATE_JSON_Response ¶
func GENERATE_JSON_Response(DATASET []interface{}) string
func GEN_JSON_HEADER ¶
func GEN_JSON_HEADER(first_element string)
func GEN_PRETTY_JSON ¶
This takes any struct and returns "regular" json and pretty colorized JSON
func GET_JSON_w_RETRY ¶
Retrieves JSON from API's using a retry method Dont forget to append strings to LIMIT_ERRORS or ABORT_ERRORS arrays if needed Returns BOOL, Byte and JSON_TEXT
func GET_KEY ¶
func GET_KEY(KEY string, inputVARS []URL_PARAMS) string
func GET_VALUE ¶
func GET_VALUE(KEY string, inputVARS []URL_PARAMS) string
Gets a value from URL params. Takes in a list of URL Params
func HAVE_ABORT_ERROR ¶
func JSON_DOWNLOAD ¶
Reveised 2023 JSON DOWNLOAD - You can send it POST statements (aafter the url... add "DO_POST" as a parameter) - If you want to changeg the HTTP timeout.. specifiy an integer (defaults to 30) - ...and for --data payloads for POST .. specifiy with a New Reader as follows:
{ "symbols": ["AAPL", "MSFT", "GOOG"], "intervals": ["1h", "1day"], "outputsize": 3, "methods": [ "time_series", { "name": "price" } ] }
- HEADERS! better header support... specify Headers as a parameter like this (with | pipe): "Content-Type|application/json" valid, JSON_BYTE, jsonTEXT, _ := JSON_DOWNLOAD(URL, "DO_POST", payload, "Content-Type|application/json")
func MAKE_API_JSON ¶
func MAKE_API_JSON(tmpOBJ interface{}) string
func MinifyJSON ¶
func OVER_THE_LIMIT ¶
= = = =Mostly API secific checks
func SEND_Response_2_Client ¶
func SEND_Response_2_Client(JSON_Response string, ClientResponseWriter *http.ResponseWriter)
Sends a response to HTTP requests. Defaults to a generic JSON response
func SHOW_ALL_PARAMS ¶
func SHOW_ALL_PARAMS(inputVARS []URL_PARAMS) string
This is mostly for debug, just shows all values in an URL_PARAMS list returns a json formatted string
func Simple_FIND_URL_key ¶
FIND_URL_key Takes in a key to search for this is similar to FIND_URL_key but doesnt use a pointer
func Start_LISTENER_SERVICE_Engine ¶
func Start_LISTENER_SERVICE_Engine(USE_PROD_MODE bool)
Types ¶
type API_ENDPOINT_DEFINITION ¶
type API_ENDPOINT_DEFINITION struct { API_Endpoint string API_Handler GENERIC_API_ENDPOINT_HANDLER }
type API_JSON_OBJ ¶
type API_JSON_OBJ struct {
DATA []interface{} `json:"data"`
}
This makes "API" json you can retrieve from jquery or VUEjs
type GENERIC_API_ENDPOINT_HANDLER ¶
type GENERIC_API_ENDPOINT_HANDLER func([]URL_PARAMS) string
This is the 'http service / routing handler' definition .. that is called... from here we call other "routeCOmmand(s)" which form the business logic. These are Controllers for the routes that are used/passed anyhting after the route/entry point is a "variable" that is consumed by the routeCommand You must ALWAYS include ?data= to trigger this.. the service will error out otherwise
func (GENERIC_API_ENDPOINT_HANDLER) ServeHTTP ¶
func (RouteEntry_Handler_FUNC_to_USE GENERIC_API_ENDPOINT_HANDLER) ServeHTTP(outgoingResponseObj http.ResponseWriter, inReq *http.Request)
type HEADER_OBJ ¶
type TMP_ERR_OBJ ¶
type URL_PARAMS ¶
func PARAM_PARSER ¶
func PARAM_PARSER(input string, PARAMLINE string) []URL_PARAMS
This parses the input prameters passed.. Supports the following formats ?name=Mary&job=librarian