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
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
generate:
buf generate
# Generate static assets for OpenAPI UI
statik -m -f -src third_party/OpenAPI/

lint:
buf lint
Expand All @@ -18,8 +16,7 @@ install:
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
github.com/rakyll/statik
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
go get \
github.com/bufbuild/buf/cmd/buf \
github.com/square/certstrap \
Expand Down
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ plugins:
out: proto
opt: paths=source_relative
- local: protoc-gen-openapiv2
out: third_party/OpenAPI
out: openapi/assets
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/bufbuild/buf v1.69.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0
github.com/rakyll/statik v0.1.7
github.com/redis/go-redis/v9 v9.19.0
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
github.com/redis/go-redis/v9 v9.19.0 h1:XPVaaPSnG6RhYf7p+rmSa9zZfeVAnWsH5h3lxthOm/k=
github.com/redis/go-redis/v9 v9.19.0/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
Expand Down
10 changes: 3 additions & 7 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import (
"os/exec"
)

// Generate protobufs and statik assets
// Generate protobufs
func Generate() error {
fmt.Println("Generating protobufs and static assets...")
if err := run("buf", "generate"); err != nil {
return err
}
return run("statik", "-m", "-f", "-src", "third_party/OpenAPI/")
fmt.Println("Generating protobufs...")
return run("buf", "generate")
}

// Lint and check for breaking changes
Expand All @@ -34,7 +31,6 @@ func Install() error {
"google.golang.org/grpc/cmd/protoc-gen-go-grpc",
"github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway",
"github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2",
"github.com/rakyll/statik",
); err != nil {
return err
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions openapi/openapi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package openapi

import "embed"

//go:embed assets
var Files embed.FS
10 changes: 5 additions & 5 deletions servers/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"compress/gzip"
"context"
"fmt"
"io/fs"
"log"
"mime"
"net/http"
Expand All @@ -31,10 +32,9 @@ import (
"github.com/7cav/api/cache"
"github.com/7cav/api/datastores"
"github.com/7cav/api/middleware"
"github.com/7cav/api/openapi"
"github.com/7cav/api/proto"
_ "github.com/7cav/api/statik" // static files import - unused in the codebase, but required cuz reasons
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/rakyll/statik/fs"
"google.golang.org/grpc"
)

Expand All @@ -55,11 +55,11 @@ func getOpenAPIHandler() http.Handler {
if err := mime.AddExtensionType(".svg", "image/svg+xml"); err != nil {
Error.Println("failed to add MIME extension type for .svg: ", err)
}
statikFs, err := fs.New()
sub, err := fs.Sub(openapi.Files, "assets")
if err != nil {
Error.Println("creating OpenAPI filesystem: ", err)
Error.Println("creating OpenAPI sub-filesystem: ", err)
}
return http.FileServer(statikFs)
return http.FileServer(http.FS(sub))
}

// maxTokenLen is the maximum length of a raw API key we'll accept.
Expand Down
14 changes: 0 additions & 14 deletions statik/statik.go

This file was deleted.

1 change: 0 additions & 1 deletion tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
_ "github.com/bufbuild/buf/cmd/buf"
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway"
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
_ "github.com/rakyll/statik"
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
)