Configure routing
This commit is contained in:
+23
@@ -4,3 +4,26 @@ config.yaml
|
|||||||
/server
|
/server
|
||||||
/vendor
|
/vendor
|
||||||
pkg/metadatapb/
|
pkg/metadatapb/
|
||||||
|
|
||||||
|
# Ignore all
|
||||||
|
*
|
||||||
|
|
||||||
|
# Unignore all with extensions
|
||||||
|
!*.*
|
||||||
|
|
||||||
|
# Unignore all dirs
|
||||||
|
!*/
|
||||||
|
|
||||||
|
### Above combination will ignore all files without extension ###
|
||||||
|
|
||||||
|
# Ignore files with extension `.class` & `.sm`
|
||||||
|
*.class
|
||||||
|
*.sm
|
||||||
|
|
||||||
|
# Ignore `bin` dir
|
||||||
|
bin/
|
||||||
|
# or
|
||||||
|
*/bin/*
|
||||||
|
|
||||||
|
# Ignore config.yaml
|
||||||
|
config.yaml
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import (
|
|||||||
|
|
||||||
// My modules
|
// My modules
|
||||||
"homelab.lan/music-agregator/internal/config"
|
"homelab.lan/music-agregator/internal/config"
|
||||||
|
appRouter "homelab.lan/music-agregator/internal/router"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).
|
log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).
|
||||||
With().Timestamp().Logger()
|
With().Timestamp().Logger()
|
||||||
router := gin.Default()
|
|
||||||
|
|
||||||
configPath := flag.String("config", "", "Path to the config file")
|
configPath := flag.String("config", "", "Path to the config file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@@ -27,12 +27,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
log.Info().Interface("config", cfg).Msg("Loaded config")
|
log.Info().Interface("config", cfg).Msg("Loaded config")
|
||||||
|
|
||||||
|
router := gin.Default()
|
||||||
|
appRouter.SetupRoutes(router)
|
||||||
router.GET("/ping", func(c *gin.Context) {
|
router.GET("/ping", func(c *gin.Context) {
|
||||||
c.JSON(200, gin.H{
|
c.JSON(200, gin.H{
|
||||||
"message": "pong",
|
"message": "pong",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
router.Run()
|
router.Run()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package indexer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetupRoutes(r *gin.RouterGroup) {
|
||||||
|
r.GET("/", func(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "hello from indexer"})
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package indexer
|
package indexer
|
||||||
|
|
||||||
import (
|
import ()
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Indexer interface {
|
type Indexer interface {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
|
"homelab.lan/music-agregator/internal/indexer"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetupRoutes(r *gin.Engine) {
|
||||||
|
api := r.Group("/api/v1")
|
||||||
|
|
||||||
|
indexerGroup := api.Group("/indexer")
|
||||||
|
|
||||||
|
indexer.SetupRoutes(indexerGroup)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user