6 Commits

Author SHA1 Message Date
837c5863fd fix security issues 2025-03-16 13:47:40 +02:00
7603f9395a security checks 2025-03-16 13:42:59 +02:00
222097af1c remove unused function 2025-03-16 13:38:14 +02:00
6ab3c33a1c linting (with failing code) 2025-03-16 13:36:53 +02:00
03839c65a0 style check 2025-03-16 13:31:55 +02:00
RDarius
e1a36f3653 Merge pull request #1 from rdarius/addtests
Readme update
2025-03-16 13:24:16 +02:00
3 changed files with 41 additions and 4 deletions

View File

@@ -18,5 +18,35 @@ jobs:
with:
go-version: "1.23.0"
- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Tests
run: go test ./... -cover
run: go test ./... -cover
- name: Security Checks
run: gosec ./...
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.0"
- name: Install staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: "latest"
- name: Style
run: test -z $(go fmt ./...)
- name: Linting
run: test -z $(go fmt ./...)

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
@@ -30,5 +31,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
_, err = w.Write(dat)
if err != nil {
fmt.Printf("Error wiring response: %s", err.Error())
return
}
}

View File

@@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/cors"
@@ -89,8 +90,9 @@ func main() {
router.Mount("/v1", v1Router)
srv := &http.Server{
Addr: ":" + port,
Handler: router,
Addr: ":" + port,
Handler: router,
ReadHeaderTimeout: time.Second * 30,
}
log.Printf("Serving on port: %s\n", port)