~repos /gromer
git clone https://pyrossh.dev/repos/gromer.git
gromer is a framework and cli to build multipage web apps in golang using htmx and alpinejs.
remove aws
- cmd/gromer/main.go +4 -12
- example/main.go +4 -14
- go.mod +1 -1
- go.sum +0 -10
- http.go +1 -3
cmd/gromer/main.go
CHANGED
|
@@ -223,7 +223,6 @@ import (
|
|
|
223
223
|
"net/http"
|
|
224
224
|
"os"
|
|
225
225
|
|
|
226
|
-
"github.com/apex/gateway/v2"
|
|
227
226
|
"github.com/gorilla/mux"
|
|
228
227
|
"github.com/pyros2097/gromer"
|
|
229
228
|
"github.com/rs/zerolog/log"
|
|
@@ -245,17 +244,10 @@ func main() {
|
|
|
245
244
|
handle(r, "GET", "/api", gromer.ApiExplorer(apiDefinitions()))
|
|
246
245
|
{{#each routes as |route| }}handle(r, "{{ route.Method }}", "{{ route.Path }}", {{ route.Pkg }}.{{ route.Method }})
|
|
247
246
|
{{/each}}
|
|
248
|
-
if !gromer.IsLambda {
|
|
249
|
-
|
|
247
|
+
println("http server listening on http://localhost:"+port)
|
|
250
|
-
|
|
248
|
+
srv := server.New(r, nil)
|
|
251
|
-
|
|
249
|
+
if err := srv.ListenAndServe(":"+port); err != nil {
|
|
252
|
-
|
|
250
|
+
log.Fatal().Stack().Err(err).Msg("failed to listen")
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
log.Print("running in lambda mode")
|
|
256
|
-
if err := gateway.ListenAndServe(":"+port, r); err != nil {
|
|
257
|
-
log.Fatal().Stack().Err(err).Msg("failed to listen")
|
|
258
|
-
}
|
|
259
251
|
}
|
|
260
252
|
}
|
|
261
253
|
|
example/main.go
CHANGED
|
@@ -7,7 +7,6 @@ import (
|
|
|
7
7
|
"net/http"
|
|
8
8
|
"os"
|
|
9
9
|
|
|
10
|
-
"github.com/apex/gateway/v2"
|
|
11
10
|
"github.com/gorilla/mux"
|
|
12
11
|
"github.com/pyros2097/gromer"
|
|
13
12
|
"github.com/rs/zerolog/log"
|
|
@@ -25,7 +24,6 @@ import (
|
|
|
25
24
|
var assetsFS embed.FS
|
|
26
25
|
|
|
27
26
|
func main() {
|
|
28
|
-
isLambda := os.Getenv("_LAMBDA_SERVER_PORT") != ""
|
|
29
27
|
r := mux.NewRouter()
|
|
30
28
|
r.Use(gromer.LogMiddleware)
|
|
31
29
|
r.NotFoundHandler = gromer.NotFoundHandler
|
|
@@ -39,18 +37,10 @@ func main() {
|
|
|
39
37
|
handle(r, "POST", "/api/todos", todos.POST)
|
|
40
38
|
handle(r, "GET", "/api/recover", recover.GET)
|
|
41
39
|
handle(r, "GET", "/", pages.GET)
|
|
42
|
-
|
|
43
|
-
if !isLambda {
|
|
44
|
-
|
|
40
|
+
println("http server listening on http://localhost:3000")
|
|
45
|
-
|
|
41
|
+
srv := server.New(r, nil)
|
|
46
|
-
|
|
42
|
+
if err := srv.ListenAndServe(":3000"); err != nil {
|
|
47
|
-
|
|
43
|
+
log.Fatal().Stack().Err(err).Msg("failed to listen")
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
log.Print("running in lambda mode")
|
|
51
|
-
if err := gateway.ListenAndServe(":3000", r); err != nil {
|
|
52
|
-
log.Fatal().Stack().Err(err).Msg("failed to listen")
|
|
53
|
-
}
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
46
|
|
go.mod
CHANGED
|
@@ -3,7 +3,6 @@ module github.com/pyros2097/gromer
|
|
|
3
3
|
go 1.16
|
|
4
4
|
|
|
5
5
|
require (
|
|
6
|
-
github.com/apex/gateway/v2 v2.0.0
|
|
7
6
|
github.com/aymerick/raymond v2.0.2+incompatible // indirect
|
|
8
7
|
github.com/bradleyjkemp/cupaloy v2.3.0+incompatible
|
|
9
8
|
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf
|
|
@@ -24,6 +23,7 @@ require (
|
|
|
24
23
|
github.com/shurcooL/highlight_diff v0.0.0-20181222201841-111da2e7d480 // indirect
|
|
25
24
|
github.com/shurcooL/highlight_go v0.0.0-20191220051317-782971ddf21b // indirect
|
|
26
25
|
github.com/shurcooL/octicon v0.0.0-20191102190552-cbb32d6a785c // indirect
|
|
26
|
+
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
|
27
27
|
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d // indirect
|
|
28
28
|
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e // indirect
|
|
29
29
|
github.com/stretchr/testify v1.7.0
|
go.sum
CHANGED
|
@@ -100,10 +100,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
|
|
|
100
100
|
github.com/GoogleCloudPlatform/cloudsql-proxy v1.24.0/go.mod h1:3tx938GhY4FC+E1KT/jNjDw7Z5qxAEtIiERJ2sXjnII=
|
|
101
101
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
|
102
102
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
|
103
|
-
github.com/apex/gateway/v2 v2.0.0 h1:tJwKiB7ObbXuF3yoqTf/CfmaZRhHB+GfilTNSCf1Wnc=
|
|
104
|
-
github.com/apex/gateway/v2 v2.0.0/go.mod h1:y+uuK0JxdvTHZeVns501/7qklBhnDHtGU0hfUQ6QIfI=
|
|
105
|
-
github.com/aws/aws-lambda-go v1.17.0 h1:Ogihmi8BnpmCNktKAGpNwSiILNNING1MiosnKUfU8m0=
|
|
106
|
-
github.com/aws/aws-lambda-go v1.17.0/go.mod h1:FEwgPLE6+8wcGBTe5cJN3JWurd1Ztm9zN4jsXsjzKKw=
|
|
107
103
|
github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
|
|
108
104
|
github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
|
109
105
|
github.com/aws/aws-sdk-go v1.40.34 h1:SBYmodndE2d4AYucuuJnOXk4MD1SFbucoIdpwKVKeSA=
|
|
@@ -148,7 +144,6 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
|
|
|
148
144
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
|
149
145
|
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
|
150
146
|
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
|
151
|
-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
|
152
147
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
|
153
148
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
154
149
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
@@ -356,7 +351,6 @@ github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
|
|
|
356
351
|
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
|
|
357
352
|
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
|
|
358
353
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
|
359
|
-
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
|
360
354
|
github.com/segmentio/go-camelcase v0.0.0-20160726192923-7085f1e3c734 h1:Cpx2WLIv6fuPvaJAHNhYOgYzk/8RcJXu/8+mOrxf2KM=
|
|
361
355
|
github.com/segmentio/go-camelcase v0.0.0-20160726192923-7085f1e3c734/go.mod h1:hqVOMAwu+ekffC3Tvq5N1ljnXRrFKcaSjbCmQ8JgYaI=
|
|
362
356
|
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
|
|
@@ -389,11 +383,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
|
|
389
383
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
390
384
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
|
391
385
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
392
|
-
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
|
|
393
|
-
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
|
|
394
386
|
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
|
395
387
|
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
|
396
|
-
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
|
397
388
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
398
389
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
399
390
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
|
@@ -827,7 +818,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
|
827
818
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
|
828
819
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
829
820
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
830
|
-
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
831
821
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
|
832
822
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
833
823
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
http.go
CHANGED
|
@@ -21,15 +21,13 @@ import (
|
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
var info *debug.BuildInfo
|
|
24
|
-
var IsLambda bool
|
|
25
24
|
var IsCloundRun bool
|
|
26
25
|
|
|
27
26
|
func init() {
|
|
28
|
-
IsLambda = os.Getenv("_LAMBDA_SERVER_PORT") != ""
|
|
29
27
|
IsCloundRun = os.Getenv("K_REVISION") != ""
|
|
30
28
|
info, _ = debug.ReadBuildInfo()
|
|
31
29
|
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
|
|
32
|
-
if !
|
|
30
|
+
if !IsCloundRun {
|
|
33
31
|
log.Logger = log.Output(zerolog.ConsoleWriter{
|
|
34
32
|
Out: os.Stdout,
|
|
35
33
|
TimeFormat: zerolog.TimeFormatUnix,
|