Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
df23da4
build(deps): update module github.com/labstack/echo/v4 to v5
renovate[bot] Jan 19, 2026
9d2f90a
fix(build): remove removed api field for echo
TheDarthMole Jan 19, 2026
d94bca8
chore(build): change all references to use echo v5
TheDarthMole Jan 19, 2026
2e453ca
perf: make big string constant
TheDarthMole Jan 21, 2026
4726703
refactor(certs): dynamically make certs as part of test
TheDarthMole Jan 21, 2026
93f6baa
fix(tests): echo start text changed causing tests to fail
TheDarthMole Jan 21, 2026
a94be54
chore(go): go mod tidy
TheDarthMole Jan 22, 2026
64ca6b2
fix(golangci-lint): fix linting errors
TheDarthMole Jan 22, 2026
afb557a
chore(docs): capitalise acronym
TheDarthMole Jan 22, 2026
74b51db
fix(server): specify the graceful timeout as 5 seconds for http server
TheDarthMole Jan 27, 2026
7f83f8e
chore(test): remove print statement
TheDarthMole Jan 27, 2026
9d06489
fix(test): specify RSA private key for test keys
TheDarthMole Jan 27, 2026
2b86064
chore(test): remove todo for code that is already implemented
TheDarthMole Jan 27, 2026
7810504
fix(swagger): update swagger to v1.5.0 to support echo v5
TheDarthMole Feb 14, 2026
ef8fbee
chore(tests): ensures handler route assertions are more dynamic
TheDarthMole Feb 14, 2026
24b6d3b
refactor(tests): create assertRoutes function to check routes exist f…
TheDarthMole Feb 14, 2026
a33ccd3
fix(server): use new context for echo validator
TheDarthMole Feb 14, 2026
be86348
fix(tests): adds better validation for validator context
TheDarthMole Feb 14, 2026
921344a
chore(go): go mod tidy
TheDarthMole Feb 14, 2026
a31cf41
chore(ci): just lint
TheDarthMole Feb 14, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ certs/
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/

### Go template
# If you prefer the allow list template instead of the deny list, see community template:
Expand Down
4 changes: 2 additions & 2 deletions cmd/upswake/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func Test_Execute(t *testing.T) {
args: []string{"upswake", "serve"},
filesystem: func() afero.Fs {
fs := afero.NewMemMapFs()
configYaml := `
const configYaml = `
nut_servers:
- name: test-nut-server
host: 127.0.0.1
Expand All @@ -206,7 +206,7 @@ nut_servers:
exitCode: 0,
timeout: 5 * time.Second,
wantOutput: []string{
"http server started on",
"http(s) server started",
"Gracefully stopping worker",
Comment thread
TheDarthMole marked this conversation as resolved.
},
notWantOutput: []string{"ERROR", "error"},
Expand Down
1 change: 1 addition & 0 deletions cmd/upswake/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (j *serveCMD) serveCmdRunE(cmd *cobra.Command, _ []string) error {
}(ctx, &wg)

err = server.Start(
j.fs,
cliArgs.ListenAddress(),
cliArgs.UseSSL,
cliArgs.CertFile,
Expand Down
4 changes: 2 additions & 2 deletions cmd/upswake/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Test_serveCmdRunE(t *testing.T) {
args: []string{"serve", "--config", "upswake.yaml", "--port", "8081"},
},
err: ErrTimeout, // expect a timeout error, as the command will run indefinitely otherwise
wantOutputs: []string{"http server started on [::]:8081"},
wantOutputs: []string{`"msg":"http(s) server started","address":"[::]:8081`},
notWantOutputs: []string{`"level":"ERROR"`, `"level":"error"`, `"level":"Error"`},
},
{
Expand Down Expand Up @@ -104,7 +104,7 @@ nut_servers:
},
err: ErrTimeout, // expect a timeout error, as the command will run indefinitely otherwise
wantOutputs: []string{
"http server started on [::]:8082",
`"msg":"http(s) server started","address":"[::]:8082"`,
`"status":200`,
`{"level":"info","ts":`,
`"msg":"REQUEST","remote_ip":"127.0.0.1","host":"127.0.0.1:8082","method":"POST","uri":"/api/upswake","user_agent":"Go-http-client/1.1","status":200}`,
Expand Down
16 changes: 6 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/go-playground/validator/v10 v10.30.1
github.com/google/uuid v1.6.0
github.com/ka-weihe/fast-levenshtein v0.0.0-20201227151214-4c99ee36a1ba
github.com/labstack/echo/v4 v4.15.0
github.com/labstack/echo/v5 v5.0.0
github.com/open-policy-agent/opa v1.13.1
github.com/robbiet480/go.nut v0.0.0-20240622015809-60e196249c53
github.com/sabhiram/go-wol v0.0.0-20250815165103-eaddd4c17972
Expand All @@ -15,7 +15,7 @@ require (
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/swaggo/echo-swagger v1.4.1
github.com/swaggo/echo-swagger v1.5.0
github.com/swaggo/swag v1.16.6
go.uber.org/zap v1.27.1
golang.org/x/crypto/x509roots/fallback v0.0.0-20260213171211-a408498e5541
Expand All @@ -30,7 +30,6 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
Expand All @@ -44,7 +43,6 @@ require (
github.com/goccy/go-json v0.10.5 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
github.com/lestrrat-go/dsig v1.0.0 // indirect
Expand All @@ -54,10 +52,9 @@ require (
github.com/lestrrat-go/jwx/v3 v3.0.13 // indirect
github.com/lestrrat-go/option/v2 v2.0.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
Expand All @@ -70,11 +67,11 @@ require (
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/files/v2 v2.0.2 // indirect
github.com/sv-tools/openapi v0.2.1 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/swaggo/swag/v2 v2.0.0-rc4 // indirect
github.com/tchap/go-patricia/v2 v2.3.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fastjson v1.6.7 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vektah/gqlparser/v2 v2.5.31 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand All @@ -89,7 +86,6 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/mod v0.31.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
Expand Down
31 changes: 12 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down Expand Up @@ -95,10 +93,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/labstack/echo/v4 v4.15.0 h1:hoRTKWcnR5STXZFe9BmYun9AMTNeSbjHi2vtDuADJ24=
github.com/labstack/echo/v4 v4.15.0/go.mod h1:xmw1clThob0BSVRX1CRQkGQ/vjwcpOMjQZSZa9fKA/c=
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/labstack/echo/v5 v5.0.0 h1:JHKGrI0cbNsNMyKvranuY0C94O4hSM7yc/HtwcV3Na4=
github.com/labstack/echo/v5 v5.0.0/go.mod h1:SyvlSdObGjRXeQfCCXW/sybkZdOOQZBmpKF0bvALaeo=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lestrrat-go/blackmagic v1.0.4 h1:IwQibdnf8l2KoO+qC3uT4OaTWsW7tuRQXy9TRN9QanA=
Expand All @@ -118,12 +114,8 @@ github.com/lestrrat-go/option/v2 v2.0.0/go.mod h1:oSySsmzMoR0iRzCDCaUfsCzxQHUEuh
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
Expand All @@ -132,6 +124,8 @@ github.com/open-policy-agent/opa v1.13.1 h1:2odxAcL3L0GNTlsuDcoguxViGxQxlpGL6zR8
github.com/open-policy-agent/opa v1.13.1/go.mod h1:M3Asy9yp1YTusUU5VQuENDe92GLmamIuceqjw+C8PHY=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -186,20 +180,20 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk=
github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc=
github.com/swaggo/files/v2 v2.0.2 h1:Bq4tgS/yxLB/3nwOMcul5oLEUKa877Ykgz3CJMVbQKU=
github.com/swaggo/files/v2 v2.0.2/go.mod h1:TVqetIzZsO9OhHX1Am9sRf9LdrFZqoK49N37KON/jr0=
github.com/sv-tools/openapi v0.2.1 h1:ES1tMQMJFGibWndMagvdoo34T1Vllxr1Nlm5wz6b1aA=
github.com/sv-tools/openapi v0.2.1/go.mod h1:k5VuZamTw1HuiS9p2Wl5YIDWzYnHG6/FgPOSFXLAhGg=
github.com/swaggo/echo-swagger v1.5.0 h1:nkHxOaBy0SkbJMtMeXZC64KHSa0mJdZFQhVqwEcMres=
github.com/swaggo/echo-swagger v1.5.0/go.mod h1:TzO363X1ZG/MSbjrG2IX6m65Yd3/zpqh5KM6lPctAhk=
github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw=
github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM=
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
github.com/swaggo/swag/v2 v2.0.0-rc4 h1:SZ8cK68gcV6cslwrJMIOqPkJELRwq4gmjvk77MrvHvY=
github.com/swaggo/swag/v2 v2.0.0-rc4/go.mod h1:Ow7Y8gF16BTCDn8YxZbyKn8FkMLRUHekv1kROJZpbvE=
github.com/tchap/go-patricia/v2 v2.3.3 h1:xfNEsODumaEcCcY3gI0hYPZ/PcpVv5ju6RMAhgwZDDc=
github.com/tchap/go-patricia/v2 v2.3.3/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fastjson v1.6.7 h1:ZE4tRy0CIkh+qDc5McjatheGX2czdn8slQjomexVpBM=
github.com/valyala/fastjson v1.6.7/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vektah/gqlparser/v2 v2.5.31 h1:YhWGA1mfTjID7qJhd1+Vxhpk5HTgydrGU9IgkWBTJ7k=
github.com/vektah/gqlparser/v2 v2.5.31/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
Expand Down Expand Up @@ -254,7 +248,6 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
Expand Down
8 changes: 4 additions & 4 deletions internal/api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const docTemplate = `{
},
"/api/servers/broadcastwake": {
"post": {
"description": "Wake a server using Wake on LAN by using the mac and enumerating all available broadcast addresses",
"description": "Wake a server using Wake on LAN by using the MAC and enumerating all available broadcast addresses",
"consumes": [
"application/json"
],
Expand All @@ -43,7 +43,7 @@ const docTemplate = `{
"tags": [
"servers"
],
"summary": "Wake a server using just a mac",
"summary": "Wake a server using just a MAC",
"parameters": [
{
"description": "Broadcast wake request",
Expand Down Expand Up @@ -79,7 +79,7 @@ const docTemplate = `{
},
"/api/servers/wake": {
"post": {
"description": "Wake a server using Wake on LAN using the mac and broadcast address provided",
"description": "Wake a server using Wake on LAN using the MAC and broadcast address provided",
"consumes": [
"application/json"
],
Expand All @@ -89,7 +89,7 @@ const docTemplate = `{
"tags": [
"servers"
],
"summary": "Wake a server using a mac and a broadcast address",
"summary": "Wake a server using a MAC and a broadcast address",
"parameters": [
{
"description": "Wake server request",
Expand Down
8 changes: 4 additions & 4 deletions internal/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"/api/servers/broadcastwake": {
"post": {
"description": "Wake a server using Wake on LAN by using the mac and enumerating all available broadcast addresses",
"description": "Wake a server using Wake on LAN by using the MAC and enumerating all available broadcast addresses",
"consumes": [
"application/json"
],
Expand All @@ -32,7 +32,7 @@
"tags": [
"servers"
],
"summary": "Wake a server using just a mac",
"summary": "Wake a server using just a MAC",
"parameters": [
{
"description": "Broadcast wake request",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"/api/servers/wake": {
"post": {
"description": "Wake a server using Wake on LAN using the mac and broadcast address provided",
"description": "Wake a server using Wake on LAN using the MAC and broadcast address provided",
"consumes": [
"application/json"
],
Expand All @@ -78,7 +78,7 @@
"tags": [
"servers"
],
"summary": "Wake a server using a mac and a broadcast address",
"summary": "Wake a server using a MAC and a broadcast address",
"parameters": [
{
"description": "Wake server request",
Expand Down
8 changes: 4 additions & 4 deletions internal/api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ paths:
post:
consumes:
- application/json
description: Wake a server using Wake on LAN by using the mac and enumerating
description: Wake a server using Wake on LAN by using the MAC and enumerating
all available broadcast addresses
parameters:
- description: Broadcast wake request
Expand All @@ -119,14 +119,14 @@ paths:
description: Wake on LAN packet failed to send
schema:
$ref: '#/definitions/handlers.Response'
summary: Wake a server using just a mac
summary: Wake a server using just a MAC
tags:
- servers
/api/servers/wake:
post:
consumes:
- application/json
description: Wake a server using Wake on LAN using the mac and broadcast address
description: Wake a server using Wake on LAN using the MAC and broadcast address
provided
parameters:
- description: Wake server request
Expand All @@ -150,7 +150,7 @@ paths:
description: Wake on LAN packet failed to send
schema:
$ref: '#/definitions/handlers.Response'
summary: Wake a server using a mac and a broadcast address
summary: Wake a server using a MAC and a broadcast address
tags:
- servers
/api/upswake:
Expand Down
12 changes: 6 additions & 6 deletions internal/api/handlers/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/TheDarthMole/UPSWake/internal/domain/entity"
"github.com/TheDarthMole/UPSWake/internal/network"
"github.com/TheDarthMole/UPSWake/internal/ups"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"github.com/spf13/afero"
echoSwagger "github.com/swaggo/echo-swagger"
)
Expand Down Expand Up @@ -52,7 +52,7 @@ func (h *RootHandler) Register(g *echo.Group) {
// @Accept plain
// @Produce html
// @Router / [get]
func (*RootHandler) Root(c echo.Context) error {
func (*RootHandler) Root(c *echo.Context) error {
return c.Redirect(http.StatusMovedPermanently, "/swagger/index.html")
}

Expand All @@ -67,24 +67,24 @@ func (*RootHandler) Root(c echo.Context) error {
// @Success 200 {object} Response "OK"
// @Failure 500 {object} Response
// @Router /health [get]
func (h *RootHandler) Health(c echo.Context) error {
func (h *RootHandler) Health(c *echo.Context) error {
if err := h.cfg.Validate(); err != nil {
return c.JSON(http.StatusInternalServerError, Response{Message: err.Error()})
}

if _, err := network.GetAllBroadcastAddresses(); err != nil {
c.Logger().Errorf("Error getting broadcast addresses: %s", err)
c.Logger().Error("Error getting broadcast addresses: " + err.Error())
return c.JSON(http.StatusInternalServerError, Response{Message: err.Error()})
}

// TODO: Speed this up by running in parallel
for _, server := range h.cfg.NutServers {
if _, err := ups.GetJSON(&server); err != nil {
c.Logger().Errorf("Error getting NUT server status: %s", err)
c.Logger().Error("Error getting NUT server status: " + err.Error())
return c.JSON(http.StatusInternalServerError, Response{Message: err.Error()})
}
}

c.Logger().Debugf("Health check OK")
c.Logger().Debug("Health check OK")
return c.JSON(http.StatusOK, Response{Message: "OK"})
}
Loading
Loading