~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.
fix router
router.go
CHANGED
|
@@ -887,11 +887,11 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
|
887
887
|
}()
|
|
888
888
|
|
|
889
889
|
path := req.URL.Path
|
|
890
|
+
println("route: " + req.URL.Path)
|
|
890
891
|
|
|
891
892
|
if root := r.trees[req.Method]; root != nil {
|
|
892
893
|
// TODO: use _ ps save it to context for useParam()
|
|
893
894
|
if handle, _, tsr := root.getValue(path, r.getParams); handle != nil {
|
|
894
|
-
println("route: " + req.URL.Path)
|
|
895
895
|
if render, ok := handle.(RenderFunc); ok {
|
|
896
896
|
w.Header().Set("Content-Type", "text/html")
|
|
897
897
|
w.WriteHeader(http.StatusOK)
|
|
@@ -928,21 +928,13 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
|
928
928
|
writePage(r.NotFound(NewRenderContext()), w)
|
|
929
929
|
}
|
|
930
930
|
|
|
931
|
-
type lambdaResponse struct {
|
|
932
|
-
StatusCode int `json:"statusCode"`
|
|
933
|
-
Headers map[string]string `json:"headers"`
|
|
934
|
-
MultiValueHeaders map[string][]string `json:"multiValueHeaders"`
|
|
935
|
-
Body string `json:"body"`
|
|
936
|
-
IsBase64Encoded bool `json:"isBase64Encoded,omitempty"`
|
|
937
|
-
}
|
|
938
|
-
|
|
939
931
|
func (r *Router) getPage(ui UI) string {
|
|
940
932
|
b := bytes.NewBuffer(nil)
|
|
941
933
|
writePage(ui, b)
|
|
942
934
|
return b.String()
|
|
943
935
|
}
|
|
944
936
|
|
|
945
|
-
func (r *Router) Lambda(ctx context.Context, e events.APIGatewayV2HTTPRequest) (res
|
|
937
|
+
func (r *Router) Lambda(ctx context.Context, e events.APIGatewayV2HTTPRequest) (res events.APIGatewayV2HTTPResponse, err error) {
|
|
946
938
|
res.StatusCode = 200
|
|
947
939
|
res.Headers = map[string]string{
|
|
948
940
|
"Content-Type": "text/html",
|
|
@@ -962,10 +954,9 @@ func (r *Router) Lambda(ctx context.Context, e events.APIGatewayV2HTTPRequest) (
|
|
|
962
954
|
}
|
|
963
955
|
}()
|
|
964
956
|
|
|
965
|
-
println("
|
|
957
|
+
println("route: " + e.RawPath)
|
|
966
|
-
path := strings.Replace(e.RawPath, "/Prod", "/", 1)
|
|
958
|
+
path := strings.Replace(e.RawPath, "/Prod/", "/", 1)
|
|
967
959
|
if root := r.trees[e.RequestContext.HTTP.Method]; root != nil {
|
|
968
|
-
// TODO: use _ ps save it to context for useParam()
|
|
969
960
|
if handle, _, _ := root.getValue(path, r.getParams); handle != nil {
|
|
970
961
|
res.Body = r.getPage(handle.(RenderFunc)(NewRenderContext()))
|
|
971
962
|
return
|