Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ba8bb7d
migrate: use gotl/pkg
CodeShellDev Nov 16, 2025
b0288c0
update dockerignore
CodeShellDev Nov 16, 2025
131d818
update Dockerfile
CodeShellDev Nov 16, 2025
237a71d
include build; don't exclude
CodeShellDev Nov 16, 2025
a2ba56b
exclude .github
CodeShellDev Nov 16, 2025
dd25cf7
update gotl
CodeShellDev Nov 16, 2025
3c3fe76
debug migration
CodeShellDev Nov 16, 2025
2cfb14e
update gotl
CodeShellDev Nov 16, 2025
21e4543
debug
CodeShellDev Nov 16, 2025
b52ce4a
more debugging
CodeShellDev Nov 16, 2025
9b7dc9e
debug before transform
CodeShellDev Nov 16, 2025
f8d81d1
debug way before
CodeShellDev Nov 16, 2025
e49832f
debug gotl
CodeShellDev Nov 16, 2025
bbf5941
use new func
CodeShellDev Nov 16, 2025
9d02e89
update gotl
CodeShellDev Nov 16, 2025
11d04b2
remove temp func
CodeShellDev Nov 16, 2025
9af3249
debug tokenconfigs
CodeShellDev Nov 16, 2025
cf8efae
inspecting data
CodeShellDev Nov 16, 2025
f29554d
debugging tokenconfig loop
CodeShellDev Nov 16, 2025
bee5d71
more debugging
CodeShellDev Nov 16, 2025
0143dad
debug slices
CodeShellDev Nov 16, 2025
6b18441
debug len of slices
CodeShellDev Nov 16, 2025
8b9fac6
use `.Get()`
CodeShellDev Nov 16, 2025
9bae62a
down grade to v0.37 in sys
CodeShellDev Nov 16, 2025
fa11de5
update go to 1.25.4
CodeShellDev Nov 16, 2025
7b83d75
update gotl
CodeShellDev Nov 16, 2025
7d93874
update gotl
CodeShellDev Nov 16, 2025
d1c37f1
remove debugs
CodeShellDev Nov 16, 2025
3167330
update to gotl `v0.0.2 - Stable`
CodeShellDev Nov 16, 2025
0e1aa69
Merge branch 'main' into migrate/to-gotl
CodeShellDev Nov 30, 2025
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
14 changes: 13 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Ignore all
*

# env file
*.env

# Exclude git folders
.git*
!.github
.github

# Ignore yml files
*.yaml
Expand All @@ -14,3 +17,12 @@

# Include data/
!data/*

# Ignore source files
*.go
go.mod
go.sum

# Include build
!app
!dist/*
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ COPY . .

COPY dist/${TARGETOS}/${TARGETARCH}/app .

RUN rm dist/ -r

CMD ["./app"]
16 changes: 9 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
module github.com/codeshelldev/secured-signal-api

go 1.25.3
go 1.25.4

require go.uber.org/zap v1.27.0
require github.com/codeshelldev/gotl v0.0.2

require go.uber.org/zap v1.27.0 // indirect

require (
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/knadh/koanf/maps v0.1.2 // indirect
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/confmap v1.0.0
github.com/knadh/koanf/providers/env/v2 v2.0.0
github.com/knadh/koanf/providers/file v1.2.0
github.com/knadh/koanf/v2 v2.3.0
github.com/knadh/koanf/providers/confmap v1.0.0 // indirect
github.com/knadh/koanf/providers/env/v2 v2.0.0 // indirect
github.com/knadh/koanf/providers/file v1.2.0 // indirect
github.com/knadh/koanf/v2 v2.3.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/sys v0.38.0 // indirect
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/codeshelldev/gotl v0.0.2 h1:PQbipYHut3DNvwcrdkQmIGo2p6X6a889Glmba/KIeFQ=
github.com/codeshelldev/gotl v0.0.2/go.mod h1:OzawxKcFw9QEgbeR5H2UXryhYeeLo8xSLme1r8viE+U=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
Expand Down Expand Up @@ -36,8 +38,8 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
28 changes: 20 additions & 8 deletions internals/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"strconv"
"strings"

"github.com/codeshelldev/gotl/pkg/configutils"
log "github.com/codeshelldev/gotl/pkg/logger"
"github.com/codeshelldev/gotl/pkg/stringutils"
"github.com/codeshelldev/secured-signal-api/internals/config/structure"
"github.com/codeshelldev/secured-signal-api/utils/configutils"
log "github.com/codeshelldev/secured-signal-api/utils/logger"

"github.com/knadh/koanf/parsers/yaml"
)
Expand Down Expand Up @@ -41,7 +42,7 @@ func Load() {

LoadTokens()

userConf.LoadEnv()
userConf.LoadEnv(normalizeEnv)

NormalizeConfig(defaultsConf)
NormalizeConfig(userConf)
Expand Down Expand Up @@ -110,18 +111,19 @@ func Normalize(config *configutils.Config, path string, structure any) {
// Load temporary config back into paths
config.Layer.Delete(path)

config.Load(tmpConf.Layer.Get("").(map[string]any), path)
config.Load(tmpConf.Layer.Raw(), path)
}

func InitReload() {
reload := func() {
reload := func(path string) {
log.Debug(path, " changed, reloading...")
Load()
Log()
}

defaultsConf.OnLoad(reload)
userConf.OnLoad(reload)
tokenConf.OnLoad(reload)
defaultsConf.OnReload(reload)
userConf.OnReload(reload)
tokenConf.OnReload(reload)
}

func InitEnv() {
Expand All @@ -139,6 +141,7 @@ func InitEnv() {
}

func LoadDefaults() {
log.Debug("Loading defaults ", ENV.DEFAULTS_PATH)
_, err := defaultsConf.LoadFile(ENV.DEFAULTS_PATH, yaml.Parser())

if err != nil {
Expand All @@ -147,6 +150,7 @@ func LoadDefaults() {
}

func LoadConfig() {
log.Debug("Loading Config ", ENV.CONFIG_PATH)
_, err := userConf.LoadFile(ENV.CONFIG_PATH, yaml.Parser())

if err != nil {
Expand All @@ -161,3 +165,11 @@ func LoadConfig() {
log.Error("Could not Load Config ", ENV.CONFIG_PATH, ": ", err.Error())
}
}

func normalizeEnv(key string, value string) (string, any) {
key = strings.ToLower(key)
key = strings.ReplaceAll(key, "__", ".")
key = strings.ReplaceAll(key, "_", "")

return key, stringutils.ToType(value)
}
12 changes: 5 additions & 7 deletions internals/config/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package config
import (
"strconv"

"github.com/codeshelldev/gotl/pkg/configutils"
log "github.com/codeshelldev/gotl/pkg/logger"
"github.com/codeshelldev/secured-signal-api/internals/config/structure"
"github.com/codeshelldev/secured-signal-api/utils/configutils"
log "github.com/codeshelldev/secured-signal-api/utils/logger"
"github.com/knadh/koanf/parsers/yaml"
)

Expand All @@ -31,17 +31,15 @@ func NormalizeTokens() {

for _, config := range tokenConf.Layer.Slices("tokenconfigs") {
tmpConf := configutils.New()
tmpConf.Load(config.Get("").(map[string]any), "")
tmpConf.Load(config.Raw(), "")

Normalize(tmpConf, "overrides", &structure.SETTINGS{})

data = append(data, tmpConf.Layer.Get("").(map[string]any))
data = append(data, tmpConf.Layer.Raw())
}

// Merge token configs together into new temporary config
tokenConf.Load(map[string]any{
"tokenconfigs": data,
}, "")
tokenConf.Load(data, "tokenconfigs")
}

func InitTokens() {
Expand Down
2 changes: 1 addition & 1 deletion internals/proxy/middlewares/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"slices"
"strings"

log "github.com/codeshelldev/gotl/pkg/logger"
"github.com/codeshelldev/secured-signal-api/internals/config"
log "github.com/codeshelldev/secured-signal-api/utils/logger"
)

var Auth Middleware = Middleware{
Expand Down
4 changes: 2 additions & 2 deletions internals/proxy/middlewares/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package middlewares

import (
"net/http"
"path"
"slices"
"strings"
"path"

log "github.com/codeshelldev/secured-signal-api/utils/logger"
log "github.com/codeshelldev/gotl/pkg/logger"
)

var Endpoints Middleware = Middleware{
Expand Down
4 changes: 2 additions & 2 deletions internals/proxy/middlewares/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package middlewares
import (
"net/http"

log "github.com/codeshelldev/secured-signal-api/utils/logger"
"github.com/codeshelldev/secured-signal-api/utils/request"
log "github.com/codeshelldev/gotl/pkg/logger"
"github.com/codeshelldev/gotl/pkg/request"
)

var Logging Middleware = Middleware{
Expand Down
6 changes: 3 additions & 3 deletions internals/proxy/middlewares/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package middlewares
import (
"net/http"

jsonutils "github.com/codeshelldev/gotl/pkg/jsonutils"
log "github.com/codeshelldev/gotl/pkg/logger"
request "github.com/codeshelldev/gotl/pkg/request"
"github.com/codeshelldev/secured-signal-api/internals/config/structure"
jsonutils "github.com/codeshelldev/secured-signal-api/utils/jsonutils"
log "github.com/codeshelldev/secured-signal-api/utils/logger"
request "github.com/codeshelldev/secured-signal-api/utils/request"
)

var Mapping Middleware = Middleware{
Expand Down
4 changes: 2 additions & 2 deletions internals/proxy/middlewares/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package middlewares
import (
"net/http"

log "github.com/codeshelldev/secured-signal-api/utils/logger"
request "github.com/codeshelldev/secured-signal-api/utils/request"
log "github.com/codeshelldev/gotl/pkg/logger"
request "github.com/codeshelldev/gotl/pkg/request"
)

var Message Middleware = Middleware{
Expand Down
2 changes: 1 addition & 1 deletion internals/proxy/middlewares/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package middlewares
import (
"net/http"

"github.com/codeshelldev/secured-signal-api/utils/logger"
"github.com/codeshelldev/gotl/pkg/logger"
)

type Middleware struct {
Expand Down
6 changes: 3 additions & 3 deletions internals/proxy/middlewares/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"net/http"
"reflect"

log "github.com/codeshelldev/gotl/pkg/logger"
request "github.com/codeshelldev/gotl/pkg/request"
"github.com/codeshelldev/secured-signal-api/internals/config/structure"
log "github.com/codeshelldev/secured-signal-api/utils/logger"
request "github.com/codeshelldev/secured-signal-api/utils/request"
"github.com/codeshelldev/secured-signal-api/utils/request/requestkeys"
"github.com/codeshelldev/secured-signal-api/utils/requestkeys"
)

var Policy Middleware = Middleware{
Expand Down
24 changes: 15 additions & 9 deletions internals/proxy/middlewares/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"regexp"
"strings"

jsonutils "github.com/codeshelldev/secured-signal-api/utils/jsonutils"
log "github.com/codeshelldev/secured-signal-api/utils/logger"
query "github.com/codeshelldev/secured-signal-api/utils/query"
request "github.com/codeshelldev/secured-signal-api/utils/request"
"github.com/codeshelldev/secured-signal-api/utils/request/requestkeys"
templating "github.com/codeshelldev/secured-signal-api/utils/templating"
jsonutils "github.com/codeshelldev/gotl/pkg/jsonutils"
log "github.com/codeshelldev/gotl/pkg/logger"
query "github.com/codeshelldev/gotl/pkg/query"
request "github.com/codeshelldev/gotl/pkg/request"
templating "github.com/codeshelldev/gotl/pkg/templating"
"github.com/codeshelldev/secured-signal-api/utils/requestkeys"
)

var Template Middleware = Middleware{
Expand Down Expand Up @@ -190,7 +190,7 @@ func TemplateBody(body map[string]any, headers map[string][]string, VARIABLES ma
maps.Copy(variables, prefixedBody)
maps.Copy(variables, prefixedHeaders)

templatedData, err := templating.RenderJSON("body", normalizedBody, variables)
templatedData, err := templating.RenderJSON(normalizedBody, variables)

if err != nil {
return body, false, err
Expand Down Expand Up @@ -235,10 +235,16 @@ func TemplateQuery(reqUrl *url.URL, data map[string]any, VARIABLES any) (string,

originalQueryData := reqUrl.Query()

addedData := query.ParseTypedQuery(templatedQuery, "@")
addedData, _ := query.ParseTypedQuery(templatedQuery)

for key, val := range addedData {
data[key] = val
keyWithoutPrefix, match := strings.CutPrefix(key, "@")

if !match {
continue
}

data[keyWithoutPrefix] = val

originalQueryData.Del(key)

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"net/http"
"os"

log "github.com/codeshelldev/gotl/pkg/logger"
config "github.com/codeshelldev/secured-signal-api/internals/config"
"github.com/codeshelldev/secured-signal-api/internals/config/structure"
reverseProxy "github.com/codeshelldev/secured-signal-api/internals/proxy"
docker "github.com/codeshelldev/secured-signal-api/utils/docker"
log "github.com/codeshelldev/secured-signal-api/utils/logger"
)

var proxy reverseProxy.Proxy
Expand Down
Loading