1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

new minor features

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-04-09 14:51:34 +03:00
parent f17a325df6
commit 4dfd4c53d3
14 changed files with 455 additions and 41 deletions

View File

@@ -12,6 +12,7 @@ import (
// for our server, including the Iris one.
type Configuration struct {
ServerName string `yaml:"ServerName"`
Env string `yaml:"Env"`
// The server's host, if empty, defaults to 0.0.0.0
Host string `yaml:"Host"`
// The server's port, e.g. 80
@@ -27,7 +28,8 @@ type Configuration struct {
// If not empty a request logger is registered,
// note that this will cost a lot in performance, use it only for debug.
RequestLog string `yaml:"RequestLog"`
// The database connection string.
ConnString string `yaml:"ConnString"`
// Iris specific configuration.
Iris iris.Configuration `yaml:"Iris"`
}

View File

@@ -1,22 +1,31 @@
package api
import (
"time"
"github.com/username/project/api/users"
"github.com/username/project/pkg/database"
"github.com/username/project/user"
"github.com/kataras/iris/v12"
"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.
srv.Any("/health", func(ctx iris.Context) {
ctx.Writef("%s\n\nOK", srv.String())
})
srv.Any("/health", modrevision.New(modrevision.Options{
ServerName: srv.config.ServerName,
Env: srv.config.Env,
Developer: "kataras",
TimeLocation: time.FixedZone("Greece/Athens", 10800),
}))
api := srv.Party("/api")
api.RegisterDependency(user.NewRepository)
api.RegisterDependency(
database.Open(srv.config.ConnString),
user.NewRepository,
)
api.PartyConfigure("/user", new(users.API))
}