File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,14 @@ import (
8
8
"path/filepath"
9
9
"strings"
10
10
11
+ "github.com/cosmos/cosmos-sdk/server/v2/api/swagger"
11
12
"github.com/pelletier/go-toml/v2"
12
13
"github.com/spf13/cobra"
13
14
"github.com/spf13/pflag"
14
15
15
16
"cosmossdk.io/core/transaction"
16
17
"cosmossdk.io/log"
18
+ "github.com/rakyll/statik/fs"
17
19
)
18
20
19
21
// ServerComponent is a server component that can be started and stopped.
@@ -73,6 +75,7 @@ var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil)
73
75
type Server [T transaction.Tx ] struct {
74
76
components []ServerComponent [T ]
75
77
config ServerConfig
78
+ router * http.ServeMux
76
79
}
77
80
78
81
func NewServer [T transaction.Tx ](
@@ -82,6 +85,7 @@ func NewServer[T transaction.Tx](
82
85
return & Server [T ]{
83
86
config : config ,
84
87
components : components ,
88
+ router : http .NewServeMux (),
85
89
}
86
90
}
87
91
@@ -242,3 +246,18 @@ func (s *Server[T]) StartFlags() []*pflag.FlagSet {
242
246
243
247
return flags
244
248
}
249
+
250
+ func (s * Server [T ]) setupSwagger () error {
251
+ cfg := s .config .API .Swagger
252
+ if ! cfg .Enable {
253
+ return nil
254
+ }
255
+
256
+ statikFS , err := fs .New ()
257
+ if err != nil {
258
+ return err
259
+ }
260
+
261
+ s .router .PathPrefix (cfg .Path ).Handler (swagger .Handler (statikFS ))
262
+ return nil
263
+ }
You can’t perform that action at this time.
0 commit comments