Documentation
¶
Index ¶
- type API
- func (j *API) ClearHeaders()
- func (j API) DebugEnabled() bool
- func (a *API) Delete(apipath string) (APIResult, error)
- func (a *API) DeleteURL(apiurl string) (APIResult, error)
- func (a *API) Get(apipath string) (APIResult, error)
- func (j API) GetBaseURL() string
- func (j API) GetTimeout() time.Duration
- func (a *API) GetURL(apiurl string) (APIResult, error)
- func (j API) InsecureSSLEnabled() bool
- func (a *API) Patch(apipath string, putdataJSON []byte) (APIResult, error)
- func (a *API) PatchURL(apiurl string, patchdataJSON []byte) (APIResult, error)
- func (a *API) Post(apipath string, postdataJSON []byte) (APIResult, error)
- func (a *API) PostForm(apiurl string, data map[string]string) (APIResult, error)
- func (a *API) PostURL(apiurl string, postdataJSON []byte) (APIResult, error)
- func (a *API) Put(apipath string, putdataJSON []byte) (APIResult, error)
- func (a *API) PutURL(apiurl string, putdataJSON []byte) (APIResult, error)
- func (j *API) SetHeaders(h map[string]string)
- func (a *API) SetLogWriter(w io.Writer)
- type APIResult
- type JwtAPI
- func (j *JwtAPI) ClearHeaders()
- func (j JwtAPI) DebugEnabled() bool
- func (j *JwtAPI) Delete(apipath string) (APIResult, error)
- func (j *JwtAPI) DeleteURL(apiurl string) (APIResult, error)
- func (j *JwtAPI) Get(apipath string) (APIResult, error)
- func (j JwtAPI) GetBaseURL() string
- func (j JwtAPI) GetRefreshTokenURI() string
- func (j JwtAPI) GetTimeout() time.Duration
- func (j JwtAPI) GetToken() Token
- func (j JwtAPI) GetTokenRequestData() TokenRequest
- func (j JwtAPI) GetTokenURI() string
- func (j *JwtAPI) GetURL(apiurl string) (APIResult, error)
- func (j JwtAPI) InsecureSSLEnabled() bool
- func (j *JwtAPI) Patch(apipath string, patchdataJSON []byte) (APIResult, error)
- func (j *JwtAPI) PatchURL(apiurl string, patchdataJSON []byte) (APIResult, error)
- func (j *JwtAPI) Post(apipath string, postdataJSON []byte) (APIResult, error)
- func (j *JwtAPI) PostURL(apiurl string, postdataJSON []byte) (APIResult, error)
- func (j *JwtAPI) Put(apipath string, putdataJSON []byte) (APIResult, error)
- func (j *JwtAPI) PutURL(apiurl string, putdataJSON []byte) (APIResult, error)
- func (j *JwtAPI) RequestTokenByCred() (Token, error)
- func (j *JwtAPI) RequestTokenByRefreshToken(rtoken string) (Token, error)
- func (j *JwtAPI) SetHeaders(h map[string]string)
- func (j *JwtAPI) SetLogWriter(w io.Writer)
- type Token
- type TokenRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { AllowInsecureSSL bool Timeout time.Duration Debug bool ResourceAPIBaseURL string StructuredResponse bool BasicAuthUser string BasicAuthPwd string UseBasicAuth bool // contains filtered or unexported fields }
API - provide functions to call APIs using GET, POST, PUT, DELETE methods to any API. It will return RawReuslt{}. API response will be read and set as string into RawResult.Data that client can parse.
func (*API) ClearHeaders ¶ added in v1.0.32
func (j *API) ClearHeaders()
func (API) DebugEnabled ¶
func (*API) Delete ¶ added in v1.0.3
Delete - make HTTP DELETE request to given api path and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*API) DeleteURL ¶ added in v1.0.3
DeleteURL - make HTTP DELETE request to given url and return RawResult{}.
func (API) GetBaseURL ¶ added in v1.0.1
func (API) GetTimeout ¶
func (*API) GetURL ¶ added in v1.0.3
GetURL - make HTTP GET request to given url and return RawResult{}.
func (API) InsecureSSLEnabled ¶
func (*API) Patch ¶ added in v1.0.33
Patch - make HTTP PATCH request to given api path, post JSON data and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*API) PatchURL ¶ added in v1.0.33
PatchURL - make HTTP PATCH request to given url and post JSON data and return RawResult{}.
func (*API) Post ¶ added in v1.0.3
Post - make HTTP POST request to given api path, post JSON data and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*API) PostForm ¶ added in v1.0.3
PostForm - make HTTP POST request to given url with content-type: application/x-www-form-urlencoded
func (*API) PostURL ¶ added in v1.0.3
PostURL - make HTTP POST request to given url and post JSON data and return RawResult{}.
func (*API) Put ¶ added in v1.0.3
Put - make HTTP PUT request to given api path, post JSON data and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*API) PutURL ¶ added in v1.0.3
PutURL - make HTTP PUT request to given url and post JSON data and return RawResult{}.
func (*API) SetHeaders ¶ added in v1.0.32
func (*API) SetLogWriter ¶ added in v1.0.3
SetLogWriter Sets io.writer for logging to file
type APIResult ¶
type APIResult struct { HTTPStatus int ErrCode int ErrText string //ErrValid tells if ErrCode and ErrText hold values from result from API or just defalut values ErrValid bool //Data hold resultant JSON as string Data string //interface{} }
APIResult is structured response returned from APIs developed by samtech09
type JwtAPI ¶
type JwtAPI struct { TokenRequestData TokenRequest TokenURI string RefreshTokenURI string AllowInsecureSSL bool Timeout time.Duration Debug bool ResourceAPIBaseURL string StructuredResponse bool // contains filtered or unexported fields }
JwtAPI provide functions to call JWT protected APIs by setting Access-Token in request Authorization header
func (*JwtAPI) ClearHeaders ¶ added in v1.0.32
func (j *JwtAPI) ClearHeaders()
func (JwtAPI) DebugEnabled ¶
func (*JwtAPI) Delete ¶
Delete - make HTTP DELETE request to given api path and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*JwtAPI) DeleteURL ¶ added in v1.0.1
DeleteURL - call given apiurl with DELETE method, auto inject Authorization Header, returns RawResult{}.
func (*JwtAPI) Get ¶
Get - make HTTP GET request to given api path and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (JwtAPI) GetBaseURL ¶ added in v1.0.1
func (JwtAPI) GetRefreshTokenURI ¶
func (JwtAPI) GetTimeout ¶
func (JwtAPI) GetTokenRequestData ¶
func (j JwtAPI) GetTokenRequestData() TokenRequest
func (JwtAPI) GetTokenURI ¶
func (*JwtAPI) GetURL ¶ added in v1.0.1
GetURL - call given apiurl with GET method, auto inject Authorization Header, returns RawResult{}.
func (JwtAPI) InsecureSSLEnabled ¶
func (*JwtAPI) Patch ¶ added in v1.0.33
Post - make HTTP PATCH request to given api path, post JSON data and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*JwtAPI) PatchURL ¶ added in v1.0.33
PostURL - call given apiurl with PATCH method and pass data, auto inject Authorization Header, returns RawResult{}.
func (*JwtAPI) Post ¶
Post - make HTTP POST request to given api path, post JSON data and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*JwtAPI) PostURL ¶ added in v1.0.1
PostURL - call given apiurl with POST method and pass data, auto inject Authorization Header, returns RawResult{}.
func (*JwtAPI) Put ¶
Put - make HTTP PUT request to given api path, post JSON data and return APIResult{}. ResourceAPIBaseURL will be prepended.
func (*JwtAPI) PutURL ¶ added in v1.0.1
PutURL - call given apiurl with PUT method and pass data, auto inject Authorization Header, returns RawResult{}.
func (*JwtAPI) RequestTokenByCred ¶
RequestTokenByCred call Token endpoint to get new token by passing TokenRequest data. It set token to JwtAPI instance for subsequent calls through same instance.
func (*JwtAPI) RequestTokenByRefreshToken ¶
RequestTokenByRefreshToken call Token endpoint to get new token by passing existing refresh-token. It set token to JwtAPI instance for subsequent calls through same instance.
func (*JwtAPI) SetHeaders ¶ added in v1.0.32
func (*JwtAPI) SetLogWriter ¶ added in v1.0.3
SetLogWriter Sets io.writer for logging to file