proxyApi

package
v0.1.43 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DbFlags map[string]bool
View Source
var ProxyListData = map[string]ProxyList{
	"Animal":      ProxyList{AuthReq: true},
	"Batch":       ProxyList{AuthReq: true},
	"Bulk":        ProxyList{AuthReq: true},
	"Carcass":     ProxyList{AuthReq: true},
	"Event":       ProxyList{AuthReq: true},
	"Location":    ProxyList{AuthReq: true},
	"Log":         ProxyList{AuthReq: true},
	"Participant": ProxyList{AuthReq: true},
	"Product":     ProxyList{AuthReq: true},
	"Role":        ProxyList{AuthReq: true},
	"User":        ProxyList{AuthReq: true},
	"UserRole":    ProxyList{AuthReq: true},
}

Functions

func DoPostToGetToken

func DoPostToGetToken(uri string, args ...string) (status int, rv string)

curl -X POST "http://18.236.106.250:31415/api/Token" -H "accept: application/json" -H "Content-Type: application/json-patch+json" -d "{ \"username\": \"enduser\", \"password\": \"...\"}"

func GetJWTToken

func GetJWTToken() string

func GuranteeCurrentToken

func GuranteeCurrentToken()

var tokenTimeLeft int var jwt_token string

func HasPort

func HasPort(s string) bool

Given a string of the form "host", "host:port", or "[ipv6::address]:port", return true if the string includes a port.

func RemoveEmptyPort

func RemoveEmptyPort(host string) string

RemoveEmptyPort strips the empty port in ":port" to "" as mandated by RFC 3986 Section 6.2.3.

func SetCommon

func SetCommon(ttlp *int, mx *sync.Mutex)

func Setup

func Setup(cfg *ProxyApiConfigType, dbf map[string]bool, lfp *os.File)

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Types

type ExtractTokenType

type ExtractTokenType struct {
	JWTToken string `json:"token"`
}

type ProxyApiConfigType

type ProxyApiConfigType struct {
	// Post JSON to this with un/pw to get a JWT token - use that as an "Authentication: Bearrer"
	// This will need to run in a go-routine and time out after the number of seconds.  A new request
	// with re-auth.
	JWTTokenUser  string `json:"jwt_token_user" default:"$ENV$JWT_TOKEN_USER"`
	JWTTokenAuth  string `json:"jwt_token_auth" default:"$ENV$JWT_TOKEN_AUTH_KEY"`
	GetJWTTimeSec int    `json:"get_jwt_time" default:"1700"`
	GetJWTTOken   string `json:"get_jwt" default:"http://dev.2c-why.com:48484/api/Token"`
}

--------------------------------------------------------------------------------------------------------- Proxy Setup - config - shuld be moved out to a "proxy" thing ---------------------------------------------------------------------------------------------------------

type ProxyConfig

type ProxyConfig struct {
	Target string
}

func SetupRedirectTo

func SetupRedirectTo(target string) (rv *ProxyConfig)

func (*ProxyConfig) HandleRedirectToProxyClosure

func (proxyConfig *ProxyConfig) HandleRedirectToProxyClosure() (fx func(w http.ResponseWriter, r *http.Request))

func (*ProxyConfig) ServeHTTP

func (p *ProxyConfig) ServeHTTP(wr http.ResponseWriter, req *http.Request)

type ProxyList

type ProxyList struct {
	Method  map[string]bool
	AuthReq bool
}

Jump to

Keyboard shortcuts

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