ax(mining): replace description comments with usage examples on InitRouter and SetupRoutes
AX Principle 2: comments show HOW with real values, not WHAT the signature already says. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
ff7acab30e
commit
f242df27aa
1 changed files with 4 additions and 6 deletions
|
|
@ -489,9 +489,8 @@ func NewService(manager ManagerInterface, listenAddr string, displayAddr string,
|
|||
}, nil
|
||||
}
|
||||
|
||||
// InitRouter initializes the Gin router and sets up all routes without starting an HTTP server.
|
||||
// Use this when embedding the mining service in another application (e.g., Wails).
|
||||
// After calling InitRouter, you can use the Router field directly as an http.Handler.
|
||||
// svc.InitRouter()
|
||||
// http.Handle("/", svc.Router) // embed as handler in Wails or another HTTP server
|
||||
func (s *Service) InitRouter() {
|
||||
s.Router = gin.Default()
|
||||
|
||||
|
|
@ -622,9 +621,8 @@ func (s *Service) ServiceStartup(ctx context.Context) error {
|
|||
return fmt.Errorf("server failed to start listening on %s within timeout", s.Server.Addr)
|
||||
}
|
||||
|
||||
// SetupRoutes configures all API routes on the Gin router.
|
||||
// This is called automatically by ServiceStartup, but can also be called
|
||||
// manually after InitRouter for embedding in other applications.
|
||||
// svc.InitRouter()
|
||||
// svc.SetupRoutes() // re-call after adding middleware manually
|
||||
func (s *Service) SetupRoutes() {
|
||||
apiGroup := s.Router.Group(s.APIBasePath)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue