(Feat): Initial Commit
Some checks failed
Build & Test / build-test (push) Has been cancelled
Build & Test / swagger-codegen-cli (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled

This commit is contained in:
2026-07-03 19:41:31 +05:30
commit 7e940c83a7
461 changed files with 45002 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package wellknown
import (
"allaboutapps.dev/aw/go-starter/internal/api"
"github.com/labstack/echo/v4"
)
func GetAndroidDigitalAssetLinksRoute(s *api.Server) *echo.Route {
return s.Router.WellKnown.GET("/assetlinks.json", getAndroidDigitalAssetLinksHandler(s))
}
func getAndroidDigitalAssetLinksHandler(s *api.Server) echo.HandlerFunc {
return func(c echo.Context) error {
if s.Config.Paths.AndroidAssetlinksFile == "" {
return echo.ErrNotFound
}
c.Response().Header().Set("Cache-Control", "public, max-age=0, must-revalidate")
c.Response().Header().Set("Content-Type", "application/json")
return c.File(s.Config.Paths.AndroidAssetlinksFile)
}
}

View File

@@ -0,0 +1,30 @@
package wellknown_test
import (
"path/filepath"
"testing"
"allaboutapps.dev/aw/go-starter/internal/api"
"allaboutapps.dev/aw/go-starter/internal/api/httperrors"
"allaboutapps.dev/aw/go-starter/internal/config"
"allaboutapps.dev/aw/go-starter/internal/test"
"allaboutapps.dev/aw/go-starter/internal/util"
"github.com/labstack/echo/v4"
)
func TestGetAndroidWellKnown(t *testing.T) {
config := config.DefaultServiceConfigFromEnv()
config.Paths.AndroidAssetlinksFile = filepath.Join(util.GetProjectRootDir(), "test", "testdata", "android-assetlinks.json")
testGetWellKnown(t, config, "/.well-known/assetlinks.json")
}
func TestGetAndroidWellKnownNotFound(t *testing.T) {
config := config.DefaultServiceConfigFromEnv()
config.Paths.AndroidAssetlinksFile = ""
test.WithTestServerConfigurable(t, config, func(s *api.Server) {
res := test.PerformRequest(t, s, "GET", "/.well-known/assetlinks.json", nil, nil)
test.RequireHTTPError(t, res, httperrors.NewFromEcho(echo.ErrNotFound))
})
}

View File

@@ -0,0 +1,21 @@
package wellknown
import (
"allaboutapps.dev/aw/go-starter/internal/api"
"github.com/labstack/echo/v4"
)
func GetAppleAppSiteAssociationRoute(s *api.Server) *echo.Route {
return s.Router.WellKnown.GET("/apple-app-site-association", getAppleAppSiteAssociationHandler(s))
}
func getAppleAppSiteAssociationHandler(s *api.Server) echo.HandlerFunc {
return func(c echo.Context) error {
if s.Config.Paths.AppleAppSiteAssociationFile == "" {
return echo.ErrNotFound
}
c.Response().Header().Set("Cache-Control", "public, max-age=0, must-revalidate")
return c.File(s.Config.Paths.AppleAppSiteAssociationFile)
}
}

View File

@@ -0,0 +1,47 @@
package wellknown_test
import (
"io"
"net/http"
"path/filepath"
"testing"
"allaboutapps.dev/aw/go-starter/internal/api"
"allaboutapps.dev/aw/go-starter/internal/api/httperrors"
"allaboutapps.dev/aw/go-starter/internal/config"
"allaboutapps.dev/aw/go-starter/internal/test"
"allaboutapps.dev/aw/go-starter/internal/util"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/require"
)
func testGetWellKnown(t *testing.T, config config.Server, path string) {
t.Helper()
test.WithTestServerConfigurable(t, config, func(s *api.Server) {
res := test.PerformRequest(t, s, "GET", path, nil, nil)
require.Equal(t, http.StatusOK, res.Result().StatusCode)
result, err := io.ReadAll(res.Body)
require.NoError(t, err)
test.Snapshoter.SaveString(t, string(result))
})
}
func TestGetAppleWellKnown(t *testing.T) {
config := config.DefaultServiceConfigFromEnv()
config.Paths.AppleAppSiteAssociationFile = filepath.Join(util.GetProjectRootDir(), "test", "testdata", "apple-app-site-association.json")
testGetWellKnown(t, config, "/.well-known/apple-app-site-association")
}
func TestGetAppleWellKnownNotFound(t *testing.T) {
config := config.DefaultServiceConfigFromEnv()
config.Paths.AppleAppSiteAssociationFile = ""
test.WithTestServerConfigurable(t, config, func(s *api.Server) {
res := test.PerformRequest(t, s, "GET", "/.well-known/apple-app-site-association", nil, nil)
test.RequireHTTPError(t, res, httperrors.NewFromEcho(echo.ErrNotFound))
})
}