Documentation ¶
Index ¶
- Constants
- func AuthenticateRequest(requestID string, config *conf.Config, requestHeader *RequestHeader, ...) bool
- func ForwardRequest(requestID string, forwardApiUrl string, incomingRespWriter http.ResponseWriter, ...) *http.Response
- func ForwardRequestReplyToIncomingRequest(startTime time.Time, requestID string, forwardApiUrl string, ...)
- func GetForwardUrl(host string, port string, forwardApiPath *http.Request) (string, error)
- func InitializeRoutes(router chi.Router)
- func InvokeDataTargetActionAuth(requestID string, config *conf.Config, ...) (int, string, error)
- func InvokeHerokuIntegrationService(requestID string, config *conf.Config, operation string, apiPath string, ...) (int, string, error)
- func InvokeSalesforceAuth(requestID string, config *conf.Config, ...) (int, string, error)
- func LogDebug(requestID string, msg string)
- func LogError(requestID string, msg string)
- func LogInfo(requestID string, msg string)
- func LogWarn(requestID string, msg string)
- func ReplyToIncomingRequest(requestID string, forwardResp *http.Response, ...)
- func ShouldBypassValidationAuthentication(requestID string, config *conf.Config, apiPath string) bool
- func TimeTrack(requestID string, startTime time.Time, name string)
- type DataActionTargetAuthRequestBody
- type InvalidRequest
- type RequestHeader
- type Routes
- type SalesforceAuthRequestBody
- type XRequestContext
Constants ¶
const ( HdrRequestContext = "x-request-context" InfoRoute = "/__herokuIntegrationServiceMeshInfo" )
Constants used across packages
const ( HdrClientContext = "x-client-context" HdrSignature = "x-signature" OrgIdQueryParam = "orgId" ApiNameQueryParam = "apiName" SalesforceExpectedHeaderCount = 2 )
const (
HdrNameRequestID = "x-request-id"
)
Variables ¶
This section is empty.
Functions ¶
func AuthenticateRequest ¶
func AuthenticateRequest( requestID string, config *conf.Config, requestHeader *RequestHeader, incomingRespWriter http.ResponseWriter, incomingReq *http.Request, incomingReqBody []byte) bool
AuthenticateRequest Authenticate request based on request type - Salesforce or Data Action Target
func ForwardRequest ¶
func ForwardRequest( requestID string, forwardApiUrl string, incomingRespWriter http.ResponseWriter, incomingReq *http.Request, incomingReqBody []byte) *http.Response
ForwardRequest Forward request to target API
func ForwardRequestReplyToIncomingRequest ¶
func ForwardRequestReplyToIncomingRequest( startTime time.Time, requestID string, forwardApiUrl string, incomingRespWriter http.ResponseWriter, incomingReq *http.Request, incomingReqBody []byte)
ForwardRequestReplyToIncomingRequest Forward request to target API; send response to incoming request
func GetForwardUrl ¶
func InitializeRoutes ¶
func InvokeDataTargetActionAuth ¶
func InvokeDataTargetActionAuth(requestID string, config *conf.Config, dataActionTargetAuthRequestBody DataActionTargetAuthRequestBody) (int, string, error)
InvokeDataTargetActionAuth Authenticate Data Action Target webhook request
func InvokeHerokuIntegrationService ¶
func InvokeHerokuIntegrationService( requestID string, config *conf.Config, operation string, apiPath string, httpMethod string, jsonBody []byte) (int, string, error)
InvokeHerokuIntegrationService Invoke given Heroku Integration API with given request JSON body.
func InvokeSalesforceAuth ¶
func InvokeSalesforceAuth(requestID string, config *conf.Config, sfAuthRequestBody SalesforceAuthRequestBody) (int, string, error)
InvokeSalesforceAuth Authenticate Salesforce request
func ReplyToIncomingRequest ¶
func ReplyToIncomingRequest(requestID string, forwardResp *http.Response, incomingRespWriter http.ResponseWriter)
ReplyToIncomingRequest Send API response to incoming response
Types ¶
type InvalidRequest ¶
func NewInvalidRequest ¶
func NewInvalidRequest(message string) *InvalidRequest
NewInvalidRequest Return when request is invalid - 401 Unauthorized
func NewMalformedRequest ¶
func NewMalformedRequest(message string) *InvalidRequest
NewMalformedRequest Return when request is structured correctly - likely a valid Salesforce/Data Cloud request, but headers or header content is incorrect - 400 Bad Request
func (*InvalidRequest) Error ¶
func (e *InvalidRequest) Error() string
func (*InvalidRequest) HttpStatusCode ¶
func (e *InvalidRequest) HttpStatusCode() int
type RequestHeader ¶
type RequestHeader struct { XRequestID string `json:"x-request-id"` XRequestContext XRequestContext `json:"x-request-context"` XClientContext string `json:"x-client-context"` XSignature string `json:"x-signature"` IsSalesforceRequest bool `json:"isDataActionTargetRequest"` }
func ValidateRequest ¶
func ValidateRequest(requestID string, headers http.Header) (*RequestHeader, error)
ValidateRequest validates the request headers based on type - Salesforce or Data Action Target.
Request Salesforce request headers:
- x-request-id
- x-request-context
- x-client-context
Required Data Action Target request headers:
- x-request-id
- x-signature
func ValidateRequestHandler ¶
func ValidateRequestHandler(requestID string, incomingRespWriter http.ResponseWriter, incomingReq *http.Request) (bool, *RequestHeader)
ValidateRequestHandler Validate request headers
type Routes ¶
type Routes struct {
// contains filtered or unexported fields
}
func (*Routes) ServiceMesh ¶
func (routes *Routes) ServiceMesh() http.HandlerFunc
ServiceMesh intercepts Heroku Integration app API requests validating and authenticating each request based on type - Salesforce or Data Action Target.
For validation rules, see ValidateRequest.
Requests are authenticated with the app's associated Heroku Integration add-on resource.
If validation and authentication are successful, the mesh forwards the request to the target app API.