functions

package
v0.0.0-...-d75042b Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 9 Imported by: 0

README

Prepare Deployment of Functions

GO111MODULE=on
go mod init && go mod vendor

Deploy Function register

gcloud functions deploy register --region europe-west3 \
    --entry-point Register --runtime go113 --trigger-http \
    --allow-unauthenticated

Test Function register

gcloud functions describe register --region europe-west3 --format='value(httpsTrigger.url)'

curl https://europe-west3-quarantine-alert-22365.cloudfunctions.net/register -d '{}'
curl https://europe-west3-quarantine-alert-22365.cloudfunctions.net/register -d '{}'

Deploy Function update

gcloud functions deploy update --region europe-west3 \
    --entry-point Update --runtime go113 --trigger-http \
    --allow-unauthenticated

Test Function update

gcloud functions describe update --region europe-west3 --format='value(httpsTrigger.url)'

curl https://europe-west3-quarantine-alert-22365.cloudfunctions.net/update -d '{"reporter":"<existing ID>","contagious":true}'

Deploy Function contacted

gcloud functions deploy contacted --region europe-west3 \
    --entry-point Contacted --runtime go113 --trigger-http \
    --allow-unauthenticated

Test Function contacted

gcloud functions describe contacted --region europe-west3 --format='value(httpsTrigger.url)'

curl https://europe-west3-quarantine-alert-22365.cloudfunctions.net/contacted -d '{"reporter":"<1st existing ID>","contact":"<2nd existing ID>"}'

Deploy Function query

gcloud functions deploy query --region europe-west3 \
    --entry-point Query --runtime go113 --trigger-http \
    --allow-unauthenticated

Test Function query

gcloud functions describe query --region europe-west3 --format='value(httpsTrigger.url)'

curl https://europe-west3-quarantine-alert-22365.cloudfunctions.net/query -d '{"requester":"<1st existing ID>"}'

Deploy Function dump

gcloud functions deploy dump --region europe-west3 \
    --entry-point Dump --runtime go113 --trigger-http \
    --allow-unauthenticated

Test Function query

gcloud functions describe query --region europe-west3 --format='value(httpsTrigger.url)'

curl https://europe-west3-quarantine-alert-22365.cloudfunctions.net/query -d '{"requester":"<1st existing ID>"}'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contacted

func Contacted(w http.ResponseWriter, r *http.Request)

Contacted inserts a contact between reporters in Firestore.

func Dump

func Dump(w http.ResponseWriter, r *http.Request)

Dump requests all contacts from Firestore

func Query

func Query(w http.ResponseWriter, r *http.Request)

Query requests a new report from Firestore related to the requester ID.

func Register

func Register(w http.ResponseWriter, r *http.Request)

Register stores a new reporter in Firestore and returns the data including its ID.

func Run

func Run()

Run starts the service.

func Update

func Update(w http.ResponseWriter, r *http.Request)

Update edits contagious status of a reporter in Firestore.

Types

type Contact

type Contact struct {
	ReporterID string `json:"reporter"`
	Opposite
}

type ContactsCollection

type ContactsCollection map[string]map[string]interface{}

Represents a flat Firestore collection

type Format

type Format struct {
	Indent bool `json:"indent"`
}

type Opposite

type Opposite struct {
	ContactID   string    `json:"contact"`
	ContactTime time.Time `json:"contact-time"`
}

type Registration

type Registration struct {
	ReporterID string `json:"reporter"`
	Contagious bool   `json:"contagious"`
	// contains filtered or unexported fields
}

type Report

type Report struct {
	RequesterID string   `json:"requester"`
	Report      []string `json:"report"`
}

Jump to

Keyboard shortcuts

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