Skip to content

Commit

Permalink
Problem: statik bring big binary size diff
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Feb 23, 2024
1 parent e344315 commit cdce3a1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 26 deletions.
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.

0 comments on commit cdce3a1

Please sign in to comment.