32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@@ -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 ./...)
|
||||
7
json.go
7
json.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
6
main.go
6
main.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user