30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
@@ -18,5 +18,35 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: "1.23.0"
|
go-version: "1.23.0"
|
||||||
|
|
||||||
|
- name: Install gosec
|
||||||
|
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||||
|
|
||||||
- name: Tests
|
- 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 ./...)
|
||||||
7
json.go
7
json.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
@@ -30,5 +31,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
w.Write(dat)
|
_, err = w.Write(dat)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error wiring response: %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
"github.com/go-chi/cors"
|
"github.com/go-chi/cors"
|
||||||
@@ -89,8 +90,9 @@ func main() {
|
|||||||
|
|
||||||
router.Mount("/v1", v1Router)
|
router.Mount("/v1", v1Router)
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr: ":" + port,
|
Addr: ":" + port,
|
||||||
Handler: router,
|
Handler: router,
|
||||||
|
ReadHeaderTimeout: time.Second * 30,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Serving on port: %s\n", port)
|
log.Printf("Serving on port: %s\n", port)
|
||||||
|
|||||||
Reference in New Issue
Block a user