Refactor to move cloud fn to top level

This commit is contained in:
Ray Miller 2023-10-08 15:05:12 +01:00
parent 28abf0e461
commit 3559ca9ec1
14 changed files with 14 additions and 13 deletions

View file

@ -5,6 +5,7 @@ Match patterns and solve anagrams - handy for crossword fanatics.
## Standalone Server
```bash
cd standalone
go run main.go
```
@ -14,7 +15,7 @@ To test using the Cloud Functions Framework:
```bash
env FUNCTION_TARGET=WordSearch WORDLIST_BUCKET=word-search-1729-assets \
WORDLIST_PATH=data/wordlist.txt LOCAL_ONLY=true go run cmd/main.go
WORDLIST_PATH=data/wordlist.txt LOCAL_ONLY=true go run ./cmd/fn-framework-test/main.go
curl 'http://localhost:8080?mode=anagrams&pattern=idea'
```

View file

@ -5,7 +5,7 @@ import (
"io"
"sort"
"github.com/ray1729/puzzle-solver/util"
"github.com/ray1729/wordsearch/util"
)
type DB interface {

View file

@ -1,4 +1,4 @@
package cloudfn
package wordsearch
import (
"bufio"
@ -12,8 +12,8 @@ import (
"cloud.google.com/go/storage"
"github.com/GoogleCloudPlatform/functions-framework-go/functions"
"github.com/ray1729/puzzle-solver/anagram"
"github.com/ray1729/puzzle-solver/match"
"github.com/ray1729/wordsearch/anagram"
"github.com/ray1729/wordsearch/match"
"github.com/rs/cors"
)

View file

@ -6,7 +6,7 @@ import (
// Blank-import the function package so the init() runs
"github.com/GoogleCloudPlatform/functions-framework-go/funcframework"
_ "github.com/ray1729/puzzle-solver/cloudfn"
_ "github.com/ray1729/wordsearch"
)
func main() {

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/ray1729/puzzle-solver
module github.com/ray1729/wordsearch
go 1.21.1

View file

@ -4,7 +4,7 @@ import (
"bufio"
"io"
"github.com/ray1729/puzzle-solver/util"
"github.com/ray1729/wordsearch/util"
)
type DB interface {

View file

@ -6,9 +6,9 @@ import (
"net/http"
"os"
"github.com/ray1729/puzzle-solver/anagram"
"github.com/ray1729/puzzle-solver/match"
"github.com/ray1729/puzzle-solver/server"
"github.com/ray1729/wordsearch/anagram"
"github.com/ray1729/wordsearch/match"
"github.com/ray1729/wordsearch/standalone/server"
)
var matchDB match.DB

View file

@ -7,8 +7,8 @@ import (
"net/http"
"sort"
"github.com/ray1729/puzzle-solver/anagram"
"github.com/ray1729/puzzle-solver/match"
"github.com/ray1729/wordsearch/anagram"
"github.com/ray1729/wordsearch/match"
)
func New(assetsPath string, matchDB match.DB, anagramDB anagram.DB) http.Handler {