Skip to content

Commit

Permalink
fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ompluscator authored and bastianccm committed Apr 17, 2019
1 parent bd794cc commit 392c252
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,5 @@ install: true
script:
- go get -u golang.org/x/lint/golint
- golint -set_exit_status $(go list ./...)
- go vet ./...
- go get -v github.com/go-lintpack/lintpack/...
- go get -v github.com/go-critic/go-critic/...
- gocritic check-project .
- go test -v ./...
- go test -v -vet=all ./...
- go test -v -race ./...
6 changes: 3 additions & 3 deletions core/oauth/application/authmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ func (am *AuthManager) OpenIDProvider() *oidc.Provider {

// OAuth2Config is lazy setup oauth2config
func (am *AuthManager) OAuth2Config(ctx context.Context, req *web.Request) *oauth2.Config {
var redirectUrl string
var redirectURL string
if req != nil {
callbackURL, _ := am.router.Absolute(req, "auth.callback", nil)
redirectUrl = callbackURL.String()
redirectURL = callbackURL.String()
}

var scopes []string
Expand All @@ -121,7 +121,7 @@ func (am *AuthManager) OAuth2Config(ctx context.Context, req *web.Request) *oaut
oauth2Config := &oauth2.Config{
ClientID: am.clientID,
ClientSecret: am.secret,
RedirectURL: redirectUrl,
RedirectURL: redirectURL,

Endpoint: am.OpenIDProvider().Endpoint(),

Expand Down
3 changes: 3 additions & 0 deletions core/security/interface/middleware/securityMiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type (
URL(context.Context, string) (*url.URL, error)
}

// RedirectURLMakerImpl is actual implementation for RedirectURLMaker interface
RedirectURLMakerImpl struct {
router web.ReverseRouter
}
Expand All @@ -49,10 +50,12 @@ type (

var _ RedirectURLMaker = new(RedirectURLMakerImpl)

// Inject dependencies
func (r *RedirectURLMakerImpl) Inject(router web.ReverseRouter) {
r.router = router
}

// URL generates absolute url depending on provided path
func (r *RedirectURLMakerImpl) URL(ctx context.Context, redirectPath string) (*url.URL, error) {
req := web.RequestFromContext(ctx)
u, err := r.router.Absolute(req, "", nil)
Expand Down
16 changes: 11 additions & 5 deletions framework/flamingo/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ type (
Notify(ctx context.Context, event Event)
}

// Flamingo default lifecycle events
StartupEvent struct{} // dispatched when the application starts
ServerStartEvent struct{} // dispatched when a server is started (not for CLI commands)
ServerShutdownEvent struct{} // dispatched when a server is stopped (not for CLI commands)
ShutdownEvent struct{} // dispatched when the application shuts down
// StartupEvent is dispatched when the application starts
StartupEvent struct{}

// ServerStartEvent is dispatched when a server is started (not for CLI commands)
ServerStartEvent struct{}

// ServerShutdownEvent is dispatched when a server is stopped (not for CLI commands)
ServerShutdownEvent struct{}

// ShutdownEvent is dispatched when the application shuts down
ShutdownEvent struct{}

eventSubscriberProvider func() []eventSubscriber

Expand Down
1 change: 1 addition & 0 deletions framework/web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
// ControllerKey exposes the current controller/handler key
ControllerKey, _ = tag.NewKey("controller")

// RouterError defines error value for issues appearing during routing process
RouterError contextKeyType = "error"
)

Expand Down
8 changes: 7 additions & 1 deletion framework/web/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type (
filterProvider func() []Filter
routesProvider func() []RoutesModule

// Router represents actual implementation of ReverseRouter interface
Router struct {
base *url.URL
external *url.URL
Expand All @@ -52,6 +53,7 @@ const (
FlamingoNotfound = "flamingo.notfound"
)

// Inject dependencies
func (r *Router) Inject(
cfg *struct {
// base url configuration
Expand Down Expand Up @@ -88,6 +90,7 @@ func (r *Router) Inject(
r.sessionName = "flamingo"
}

// Handler creates and returns new instance of http.Handler interface
func (r *Router) Handler() http.Handler {
r.routerRegistry = NewRegistry()

Expand Down Expand Up @@ -125,18 +128,21 @@ func (r *Router) Handler() http.Handler {
}
}

// ListenAndServe starts flamingo server
func (r *Router) ListenAndServe(addr string) error {
r.eventRouter.Dispatch(context.Background(), &flamingo.ServerStartEvent{})
defer r.eventRouter.Dispatch(context.Background(), &flamingo.ServerShutdownEvent{})

return http.ListenAndServe(addr, r.Handler())
}

// Base returns full base urls, containing scheme, domain and base path
func (r *Router) Base() *url.URL {
return r.base
}

// deprecated
// URL returns returns a root-relative URL, starting with `/`
// Deprecated: use Relative instead
func (r *Router) URL(to string, params map[string]string) (*url.URL, error) {
return r.Relative(to, params)
}
Expand Down

0 comments on commit 392c252

Please sign in to comment.