2021-11-19 13:13:42 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2022-04-09 13:51:34 +02:00
|
|
|
"time"
|
|
|
|
|
2021-11-19 13:13:42 +01:00
|
|
|
"github.com/username/project/api/users"
|
2022-04-09 13:51:34 +02:00
|
|
|
"github.com/username/project/pkg/database"
|
2021-11-19 13:13:42 +01:00
|
|
|
"github.com/username/project/user"
|
|
|
|
|
2022-04-09 13:51:34 +02:00
|
|
|
"github.com/kataras/iris/v12/middleware/modrevision"
|
2021-11-19 13:13:42 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// buildRouter is the most important part of your server.
|
|
|
|
// All root endpoints are registered here.
|
|
|
|
func (srv *Server) buildRouter() {
|
|
|
|
// Add a simple health route.
|
2022-04-09 13:51:34 +02:00
|
|
|
srv.Any("/health", modrevision.New(modrevision.Options{
|
|
|
|
ServerName: srv.config.ServerName,
|
|
|
|
Env: srv.config.Env,
|
|
|
|
Developer: "kataras",
|
2022-06-17 21:03:18 +02:00
|
|
|
TimeLocation: time.FixedZone("Greece/Athens", 7200),
|
2022-04-09 13:51:34 +02:00
|
|
|
}))
|
2021-11-19 13:13:42 +01:00
|
|
|
|
|
|
|
api := srv.Party("/api")
|
2022-04-09 13:51:34 +02:00
|
|
|
api.RegisterDependency(
|
|
|
|
database.Open(srv.config.ConnString),
|
|
|
|
user.NewRepository,
|
|
|
|
)
|
2021-11-19 13:13:42 +01:00
|
|
|
|
|
|
|
api.PartyConfigure("/user", new(users.API))
|
|
|
|
}
|