CUSTOM_GOMOD

package module
v0.0.0-...-a03493e Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ALL_COUNT = 0
View Source
var ALL_JSON_RESULTS = ""
View Source
var ALL_SERVICE_ENDPOINTS []API_ENDPOINT_DEFINITION
View Source
var API_DEBUG_ENABLED = false
View Source
var DEFAULT_LISTEN_PORT = "8888" // This is the default "listen" port for all webservices.. if using ports below 1024 you must run as root
View Source
var JSON_BOTTOM = `
  ]
}
`
View Source
var JSON_CLEAN_FLAG = false // When set to TRUE, we return "MINIFIED" json  (it omits whatever spaces and indents you used get stripped out )
View Source
var JSON_DATA_HEADER = `
  "data" : [
    `
View Source
var JSON_TOP = `
{
`
View Source
var MAX_JSON_RETRY_ATTEMPTS = 5
View Source
var MAX_JSON_SLEEP_VAL = 10
View Source
var SSL_CERT_PEM_FILE = "" // Full path to wherever this CERT/ pem file is			(this is just example: /opt/SSL_CERTS/biolab_COMBINED.pem  )
View Source
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
View Source
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 )
View Source
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

func FIND_URL_key(keyname string, UMAP url.Values, myresult *string) bool
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 FIND_VALUE

func FIND_VALUE(KEY string, inputVARS []URL_PARAMS) string

Alias to GET_VALUE

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

func GEN_PRETTY_JSON(tmpOBJ interface{}) (string, string)

This takes any struct and returns "regular" json and pretty colorized JSON

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 JSON_DOWNLOAD

func JSON_DOWNLOAD(API_URL string, PARAMS ...interface{}) (bool, []byte, string, error)

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 MINI_WEB

func MINI_WEB(WEBROOT string, listenPort string, START_MESSAGE string, USE_PROD_MODE bool)

This is a mini/micro Web Server

func MinifyJSON

func MinifyJSON(str string) string

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

func Simple_FIND_URL_key(keyname string, UMAP url.Values) (bool, string)

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 HEADER_OBJ struct {
	NAME  string
	VALUE string
}

type URL_PARAMS

type URL_PARAMS struct {
	KEY   string
	Value string
}

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

Jump to

Keyboard shortcuts

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