Is it possible to define a route from a plugin? Or...
# ktor
a
Is it possible to define a route from a plugin? Or is that really the wrong way to go about? EDIT: well,
application.routing
works obviously. However, I run into problems when it is a route scoped route. Okay, so the
route
isn't the
route
I was expecting. I am wondering how I install a route in a route-scoped plugin. So imagine the route is at
/foo
I want the plugin to install at
/bar
r
If I understood your question right, you install route-scoped plugins in the route body.
Copy code
route("the-path") {
    install(ThePlugin)
}
a
Yes I know that, but I was wondering if I can CREATE routes in the custom route based plugin
j
You can’t, Renan’s answer is the way to go.
o
What is your task?
a
I am creating a plugin that, based on its configuration, needs to expose some routes.
In an application level plugin this works:
Copy code
val AssetMapperPlugin = createApplicationPlugin(name, { AssetMapperConfiguration() }) {
....
    application.routing {
        get(...) {
        }

        staticResources(pluginConfig.remotePath, pluginConfig.basePackage)
    }
}