Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true

- name: go vet
run: go vet ./...

- name: go test
run: go test ./...

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.11.3
19 changes: 19 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "2"

linters:
default: none
enable:
- errcheck
- govet
- staticcheck
settings:
errcheck:
# Report errors from type assertions (e.g. v, ok := x.(T) when ok is ignored)
check-type-assertions: true
# Report when errors are assigned to the blank identifier
check-blank: true

issues:
# Don't limit the number of issues per linter
max-issues-per-linter: 0
max-same-issues: 0
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ RUN chown -R appuser:appuser /app

USER appuser

EXPOSE 8080
EXPOSE 3000

HEALTHCHECK --interval=10s --timeout=3s CMD wget -qO- http://localhost:8080/healthz || exit 1
HEALTHCHECK --interval=10s --timeout=3s CMD wget -qO- http://127.0.0.1:3000/healthz || exit 1

CMD ["/bin/ingest"]
13 changes: 10 additions & 3 deletions internal/server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ func RequestID() fiber.Handler {
// RequestLogger logs each incoming request with structured fields.
func RequestLogger(logger *slog.Logger) fiber.Handler {
return func(c fiber.Ctx) error {
requestID, _ := c.Locals("request_id").(string)
var requestID string
if id, ok := c.Locals("request_id").(string); ok {
requestID = id
}

logger.Info("request started",
"request_id", requestID,
Expand Down Expand Up @@ -70,15 +73,19 @@ func GzipDecompress() fiber.Handler {
"error": "invalid gzip body",
})
}
defer reader.Close()

decompressed, err := io.ReadAll(reader)
if err != nil {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "failed to decompress gzip body",
})
}

if err := reader.Close(); err != nil {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "invalid gzip body",
})
}

// Replace the request body with decompressed content
c.Request().SetBody(decompressed)
c.Request().Header.Del("Content-Encoding")
Expand Down
1 change: 1 addition & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tools]
go = "1.26"
air = "latest"
golangci-lint = "2.11.3"

[env]
CGO_ENABLED = "0"
Expand Down
Loading