Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Load routes safely in SwaggerPlugin #145

Closed

Conversation

byamba-tumurkhuu
Copy link

I have a router that extends SimpleRouter:

class ApiRouter(controller: ApiController) extends SimpleRouter
{
  override def routes: Routes = {
    case GET(p"/") => controller.index
  }
}

And my routes file:

->         /                  ApiRouter

However when SwaggerPlugin loads the routes during the app initialization, it tries to load ApiRouter as a file thus throwing NullPointerException at the following code:

Source.fromInputStream(app.classloader.getResourceAsStream(routesFile)).mkString

This PR ignores any exceptions when loading routes and logs in debug level.

@byamba-tumurkhuu
Copy link
Author

@fehguy @rayyildiz

@MatteCarra
Copy link

This isn't a viable solution.
You are just ignoring all this routes.

@byamba-tumurkhuu
Copy link
Author

byamba-tumurkhuu commented Aug 9, 2017

They're ignored because they can't be loaded. It's better to log if there is any problem during the loading, rather than killing the app with exception.

@MatteCarra
Copy link

Yes that's true.
I was hoping to find a better solution but it is impossible

@byamba-tumurkhuu
Copy link
Author

Unfortunately I'm not getting any reviews.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants