Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: statik bring big binary size diff #1035

Merged
merged 1 commit into from
Feb 23, 2024
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
10 changes: 4 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"net/http"
"os"
"path/filepath"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
"golang.org/x/exp/slices"

Expand Down Expand Up @@ -140,9 +140,7 @@ import (
supplykeeper "github.com/crypto-org-chain/chain-main/v4/x/supply/keeper"
supplytypes "github.com/crypto-org-chain/chain-main/v4/x/supply/types"

// unnamed import of statik for swagger UI support
_ "github.com/crypto-org-chain/chain-main/v4/app/docs/statik"

"github.com/crypto-org-chain/chain-main/v4/app/docs"
memiavlstore "github.com/crypto-org-chain/cronos/store"
)

Expand Down Expand Up @@ -878,12 +876,12 @@ func (app *ChainApp) RegisterNodeService(clientCtx client.Context) {

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
statikFS, err := fs.NewWithNamespace("chainmain")
root, err := fs.Sub(docs.SwaggerUI, "swagger-ui")
if err != nil {
panic(err)
}

staticServer := http.FileServer(statikFS)
staticServer := http.FileServer(http.FS(root))
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer))
}

Expand Down
6 changes: 6 additions & 0 deletions app/docs/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package docs

import "embed"

//go:embed swagger-ui
var SwaggerUI embed.FS
3 changes: 0 additions & 3 deletions app/docs/statik/init.go

This file was deleted.

14 changes: 0 additions & 14 deletions app/docs/statik/statik.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/imdario/mergo v0.3.13
github.com/linxGnu/grocksdb v1.8.4
github.com/rakyll/statik v0.1.7
github.com/rakyll/statik v0.1.7 // indirect
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
Expand Down
2 changes: 0 additions & 2 deletions scripts/update-swagger-ui-statik.sh

This file was deleted.

Loading