Skip to content

Commit

Permalink
add ping functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pankona committed Jan 27, 2022
1 parent 5f5bcf2 commit fec3c0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hashira-web/functions/Makefile
Expand Up @@ -2,18 +2,22 @@ test:
go test ./...

deploy-all:
make deploy-ping
make deploy-upload
make deploy-download
make deploy-test-access-token

deploy-ping:
gcloud functions deploy ping --entry-point Ping --runtime go116 --memory 256MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10

deploy-upload:
gcloud functions deploy upload --entry-point Upload --runtime go116 --memory 128MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10
gcloud functions deploy upload --entry-point Upload --runtime go116 --memory 256MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10

deploy-download:
gcloud functions deploy download --entry-point Download --runtime go116 --memory 128MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10
gcloud functions deploy download --entry-point Download --runtime go116 --memory 256MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10

deploy-add:
gcloud functions deploy add --entry-point Add --runtime go116 --memory 128MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10
gcloud functions deploy add --entry-point Add --runtime go116 --memory 256MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10

deploy-test-access-token:
gcloud functions deploy test-access-token --entry-point TestAccessToken --runtime go116 --memory 128MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10
gcloud functions deploy test-access-token --entry-point TestAccessToken --runtime go116 --memory 256MB --trigger-http --allow-unauthenticated --region asia-northeast1 --max-instances 10
8 changes: 8 additions & 0 deletions hashira-web/functions/func.go
@@ -1,12 +1,20 @@
package functions

import (
"log"
"net/http"

"github.com/pankona/hashira/hashira-web/functions/hashira"
"github.com/pankona/hashira/hashira-web/functions/hashira/store"
)

func Ping(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte("pong")); err != nil {
log.Printf("ping failed: %v", err)
}
}

func TestAccessToken(w http.ResponseWriter, r *http.Request) {
setHeadersForCORS(w)
if r.Method == http.MethodOptions {
Expand Down

0 comments on commit fec3c0a

Please sign in to comment.