Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions cmd/tegola_lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,40 @@ import (
"net/url"
"os"

"github.com/arolek/algnhsa"
"github.com/akrylysov/algnhsa"
"github.com/dimfeld/httptreemux"

"github.com/go-spatial/tegola/atlas"
"github.com/go-spatial/tegola/cmd/internal/register"
"github.com/go-spatial/tegola/config"
"github.com/go-spatial/tegola/dict"
"github.com/go-spatial/tegola/mvt"
"github.com/go-spatial/tegola/server"
)

// set at build time via the CI
var Version = "version not set"
var (
// Version set at build time via the CI
Version = "version not set"
// mux is a reference to the http muxer. it's stored as a package
// var so we can take advantage of Lambda's "Global State".
mux *httptreemux.TreeMux
)

const DefaultConfLocation = "config.toml"

// instantiate the server during the init() function and then store
// the muxer in a package variable. This allows us to take advantage
// of "Global State" to avoid needing to re-parse the config, connect
// to databases, tile caches, etc. on each function invocation.
//
// For more info, see Using Global State:
// https://docs.aws.amazon.com/lambda/latest/dg/go-programming-model-handler-types.html
func init() {
var err error

// override the URLRoot func with a lambda specific one
server.URLRoot = URLRoot
}

func main() {
var err error

confLocation := "config.toml"
confLocation := DefaultConfLocation

// check if the env TEGOLA_CONFIG is set
if os.Getenv("TEGOLA_CONFIG") != "" {
Expand Down Expand Up @@ -98,13 +111,18 @@ func main() {
}

// http route setup
mux := server.NewRouter(nil)
mux = server.NewRouter(nil)
}

func main() {
// the second argument here tells algnhasa to watch for the MVT MimeType Content-Type headers
// if it detects this in the response the payload will be base64 encoded. Lambda needs to be configured
// to handle binary responses so it can convert the base64 encoded payload back into binary prior
// to sending to the client
algnhsa.ListenAndServe(mux, []string{mvt.MimeType})
algnhsa.ListenAndServe(mux, &algnhsa.Options{
BinaryContentTypes: []string{"application/vnd.mapbox-vector-tile"},
UseProxyPath: true,
})
}

// URLRoot overrides the default server.URLRoot function in order to include the "stage" part of the root
Expand Down
39 changes: 39 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/adapter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/alb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/apigw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/github.com/akrylysov/algnhsa/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading