iris/_examples/project/api/router.go

32 lines
757 B
Go
Raw Normal View History

package api
import (
2022-04-09 13:51:34 +02:00
"time"
"github.com/username/project/api/users"
2022-04-09 13:51:34 +02:00
"github.com/username/project/pkg/database"
"github.com/username/project/user"
2022-04-09 13:51:34 +02:00
"github.com/kataras/iris/v12/middleware/modrevision"
)
// 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",
TimeLocation: time.FixedZone("Greece/Athens", 7200),
2022-04-09 13:51:34 +02:00
}))
api := srv.Party("/api")
2022-04-09 13:51:34 +02:00
api.RegisterDependency(
database.Open(srv.config.ConnString),
user.NewRepository,
)
api.PartyConfigure("/user", new(users.API))
}