function

package module
v0.0.0-...-3732a2f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 22 Imported by: 0

README

tudura

How to Deploy

GCPの以下のサービスを使用するので有効化しておいてください。

  • Cloud Functions
  • Cloud SQL
  • Cloud Storage
  • Firestore
  • VPC Network
    • Serverless VPC Access

gcloudコマンドラインツールを使用するのでインストールしておいてください。

以下、共通のリージョンを使用してください。

  1. VPCネットワークの作成 VPCネットワークから新しいネットワークを作成します。 サブネットは作成しなくて構いません。 プライベートサービス接続からIP範囲の割り当てを作成します。 この時、既存のネットワークと重複しないようにしてください。

  2. DBの作成 新しいインスタンスをMySQL 8.0, プライベートネットワーク(上記で作成したコネクタを使用)で作成します。 CloudStorage上の適当な場所にアップロードしたinit.sqlをインポートし、DBの初期化を行います。

  3. バケットの作成 Storageから新しいバケットを作成してください。

  4. 設定ファイルの作成 .env.yamlをプロジェクトルートに作成し、以下の項目を埋めてください。

  • PROJECT_ID: プロジェクト名
  • BUCKET: バケット名
  • INSTANCE_CONNECTION_NAME: サーバレスVPCコネクション名
  • MYSQL_HOST: DBのプライベートIP
  • MYSQL_PASS: DBのパスワード

例:

PROJECT_ID: "tudura"
BUCKET: "tudura"
INSTANCE_CONNECTION_NAME: "tudura:asia-northeast1:tudura-staging"
MYSQL_HOST: "192.168.1.3"
MYSQL_PASS: "p4s5w0rd"
  1. 関数のデプロイ make deploy f={{ 関数名 }}でデプロイできます。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trace   *log.Logger
	Info    *log.Logger
	Warning *log.Logger
	Error   *log.Logger
)
View Source
var (
	UnauthorizedError = errors.New("401 StatusUnauthorized")
)

Functions

func AuthBoxHandler

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

AuthBoxHandler /boxes/{boxId}/auth ボックスに対する認証を行い、Cookieを付与

func DownloadItemHandler

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

TODO: 一括アップロード可能に DownloadItemHandler POST /boxes/{boxId}/d/{itemId} アイテムのダウンロード

func GetBoxHandler

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

GetBoxHandler POST /boxes/{boxId} ボックスの概要を取得

func GetItemHandler

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

GetItemHandler POST /boxes/{boxId}/{itemId} アイテムの詳細を取得

func Hello

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

Hello sample function

func PostBoxHandler

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

PostBoxHandler POST /boxes ボックスの作成

func PostItemHandler

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

TODO: 一括アップロード可能に PostItemHandler POST /boxes/{boxId} アイテムのアップロード

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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