Skip to content

Commit

Permalink
Merge pull request #149 from zhu327/feat_cors
Browse files Browse the repository at this point in the history
feat: application add UseGlobal method
  • Loading branch information
john-deng authored Dec 18, 2024
2 parents fbdcec6 + d6e48da commit 489a58d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/hidevopsio/hiboot/pkg/system/scheduler"
"github.com/hidevopsio/hiboot/pkg/utils/cmap"
"github.com/hidevopsio/hiboot/pkg/utils/io"
"github.com/kataras/iris/core/router"
)

const (
Expand Down Expand Up @@ -60,6 +61,7 @@ type ApplicationContext interface {
Use(handlers ...context.Handler)
GetProperty(name string) (value interface{}, ok bool)
GetInstance(params ...interface{}) (instance interface{})
WrapRouter(handler router.WrapperFunc)
}

// BaseApplication is the base application
Expand All @@ -83,7 +85,7 @@ var (
configContainer []*factory.MetaData
componentContainer []*factory.MetaData
// Profiles include profiles initially
Profiles []string
Profiles []string

// ErrInvalidObjectType indicates that configuration type is invalid
ErrInvalidObjectType = errors.New("[app] invalid Configuration type, one of app.Configuration need to be embedded")
Expand Down
8 changes: 7 additions & 1 deletion pkg/app/fake/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
// Package fake provides fake.ApplicationContext for unit testing
package fake

import "github.com/hidevopsio/hiboot/pkg/app/web/context"
import (
"github.com/hidevopsio/hiboot/pkg/app/web/context"
"github.com/kataras/iris/core/router"
)

// ApplicationContext application context
type ApplicationContext struct {
Expand All @@ -40,3 +43,6 @@ func (a *ApplicationContext) GetProperty(name string) (value interface{}, ok boo
func (a *ApplicationContext) GetInstance(params ...interface{}) (instance interface{}) {
return
}

func (a *ApplicationContext) WrapRouter(handler router.WrapperFunc) {
}
7 changes: 6 additions & 1 deletion pkg/app/web/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"regexp"
"time"

"github.com/kataras/iris"
"github.com/hidevopsio/hiboot/pkg/app"
"github.com/hidevopsio/hiboot/pkg/app/web/context"
"github.com/hidevopsio/hiboot/pkg/at"
"github.com/hidevopsio/hiboot/pkg/log"
"github.com/hidevopsio/hiboot/pkg/utils/io"
"github.com/kataras/iris"
"github.com/kataras/iris/core/router"
)

const (
Expand Down Expand Up @@ -190,6 +191,10 @@ func (a *application) Use(handlers ...context.Handler) {
}
}

func (a *application) WrapRouter(handler router.WrapperFunc) {
a.webApp.WrapRouter(handler)
}

func (a *application) initialize(controllers ...interface{}) (err error) {
io.EnsureWorkDir(3, "config/application.yml")

Expand Down

0 comments on commit 489a58d

Please sign in to comment.