Documentation ¶
Index ¶
- Constants
- func NewInterServiceClient(serviceName string, ext ExternalMethodsExtension) *interserviceclient.InterServiceClient
- type External
- func (e *External) AuthenticateCustomFirebaseToken(customAuthToken string) (*firebasetools.FirebaseUserTokens, error)
- func (e *External) CreateFirebaseCustomToken(ctx context.Context, uid string) (string, error)
- func (e *External) CreateFirebaseCustomTokenWithClaims(ctx context.Context, uid string, claims map[string]interface{}) (string, error)
- func (e *External) EnsureSubscriptionsExist(ctx context.Context, pubsubClient *pubsub.Client, ...) error
- func (e *External) EnsureTopicsExist(ctx context.Context, pubsubClient *pubsub.Client, topicIDs []string) error
- func (e *External) GetLoggedInUserUID(ctx context.Context) (string, error)
- func (*External) LoadDepsFromYAML() (*interserviceclient.DepsConfig, error)
- func (e *External) Login(ctx context.Context) http.HandlerFunc
- func (e *External) MakeRequest(ctx context.Context, method string, path string, body interface{}) (*http.Response, error)
- func (e *External) PublishToPubsub(ctx context.Context, pubsubClient *pubsub.Client, topicID string, ...) error
- func (*External) SetupISCclient(config interserviceclient.DepsConfig, serviceName string) (*interserviceclient.InterServiceClient, error)
- func (e *External) VerifyPubSubJWTAndDecodePayload(w http.ResponseWriter, r *http.Request) (*pubsubtools.PubSubPayload, error)
- type ExternalMethodsExtension
- type ISCClientExtension
Constants ¶
const ( // DjangoAuthorizationToken is used as an authorization token for making request to our // django backend service DjangoAuthorizationToken = "DJANGO_AUTHORIZATION_TOKEN" )
Variables ¶
This section is empty.
Functions ¶
func NewInterServiceClient ¶
func NewInterServiceClient(serviceName string, ext ExternalMethodsExtension) *interserviceclient.InterServiceClient
NewInterServiceClient initializes an external service in the correct environment given its name
Types ¶
type External ¶
type External struct { }
External type implements external methods
func (*External) AuthenticateCustomFirebaseToken ¶
func (e *External) AuthenticateCustomFirebaseToken(customAuthToken string) (*firebasetools.FirebaseUserTokens, error)
AuthenticateCustomFirebaseToken takes a custom Firebase auth token and tries to fetch an ID token If successful, a pointer to the ID token is returned Otherwise, an error is returned
func (*External) CreateFirebaseCustomToken ¶
CreateFirebaseCustomToken creates a custom auth token for the user with the indicated UID
func (*External) CreateFirebaseCustomTokenWithClaims ¶
func (e *External) CreateFirebaseCustomTokenWithClaims(ctx context.Context, uid string, claims map[string]interface{}) (string, error)
CreateFirebaseCustomTokenWithClaims creates a custom auth token for the user with the indicated UID and additional claims
func (*External) EnsureSubscriptionsExist ¶
func (e *External) EnsureSubscriptionsExist(ctx context.Context, pubsubClient *pubsub.Client, topicSubscriptionMap map[string]string, callbackURL string) error
EnsureSubscriptionsExist ensures that the subscriptions named in the supplied topic:subscription map exist. If any does not exist, it is created.
func (*External) EnsureTopicsExist ¶
func (e *External) EnsureTopicsExist(ctx context.Context, pubsubClient *pubsub.Client, topicIDs []string) error
EnsureTopicsExist creates the topic(s) in the suppplied list if they do not already exist.
func (*External) GetLoggedInUserUID ¶
GetLoggedInUserUID get the logged in user uid
func (*External) LoadDepsFromYAML ¶
func (*External) LoadDepsFromYAML() (*interserviceclient.DepsConfig, error)
LoadDepsFromYAML loads the dependency config
func (*External) Login ¶
func (e *External) Login(ctx context.Context) http.HandlerFunc
Login authenticates against firebase to return a valid token
func (*External) MakeRequest ¶
func (e *External) MakeRequest(ctx context.Context, method string, path string, body interface{}) (*http.Response, error)
MakeRequest performs a http request and returns a response
func (*External) PublishToPubsub ¶
func (e *External) PublishToPubsub(ctx context.Context, pubsubClient *pubsub.Client, topicID string, environment string, serviceName string, version string, payload []byte) error
PublishToPubsub sends the supplied payload to the indicated topic
func (*External) SetupISCclient ¶
func (*External) SetupISCclient(config interserviceclient.DepsConfig, serviceName string) (*interserviceclient.InterServiceClient, error)
SetupISCclient creates an isc client
func (*External) VerifyPubSubJWTAndDecodePayload ¶
func (e *External) VerifyPubSubJWTAndDecodePayload(w http.ResponseWriter, r *http.Request) (*pubsubtools.PubSubPayload, error)
VerifyPubSubJWTAndDecodePayload confirms that there is a valid Google signed JWT and decodes the pubsub message payload into a struct.
It's use will simplify & shorten the handler funcs that process Cloud Pubsub push notifications.
type ExternalMethodsExtension ¶
type ExternalMethodsExtension interface { CreateFirebaseCustomToken(ctx context.Context, uid string) (string, error) CreateFirebaseCustomTokenWithClaims(ctx context.Context, uid string, claims map[string]interface{}) (string, error) AuthenticateCustomFirebaseToken(customAuthToken string) (*firebasetools.FirebaseUserTokens, error) GetLoggedInUserUID(ctx context.Context) (string, error) MakeRequest(ctx context.Context, method string, path string, body interface{}) (*http.Response, error) Login(ctx context.Context) http.HandlerFunc PublishToPubsub(ctx context.Context, pubsubClient *pubsub.Client, topicID string, environment string, serviceName string, version string, payload []byte) error EnsureTopicsExist(ctx context.Context, pubsubClient *pubsub.Client, topicIDs []string) error EnsureSubscriptionsExist(ctx context.Context, pubsubClient *pubsub.Client, topicSubscriptionMap map[string]string, callbackURL string) error VerifyPubSubJWTAndDecodePayload(w http.ResponseWriter, r *http.Request) (*pubsubtools.PubSubPayload, error) LoadDepsFromYAML() (*interserviceclient.DepsConfig, error) SetupISCclient(config interserviceclient.DepsConfig, serviceName string) (*interserviceclient.InterServiceClient, error) }
ExternalMethodsExtension is an interface that represents methods that are called from external libraries. Adding this layer will help write unit tests
func NewExternalMethodsImpl ¶
func NewExternalMethodsImpl() ExternalMethodsExtension
NewExternalMethodsImpl creates a new instance of the external methods