CommandBox/CfConfig and REST

I’m looking for a way to streamline our deveops, and I’ve been playing around with CommandBox and CfConfig a lot, both seem promising. I see you can enable and configure the server-wide REST handler via CommandBox in server.json (REST Servlet - CommandBox : CLI, Package Manager, REPL & More)

server set app.restMappings=/rest/*,/api/*

And I see you can set-up regular mappings via CfConfig (Config Items - CFConfig Documentation)

#Key is virtual path, value is struct of properties 
name='CFMappings' type='struct'

But is there a way to configure the REST mappings that doesn’t involve copying/editing lucee-web.xml or going into the Administrator page?

@eddie_b Sorry for not replying to this-- I never saw this topic until today when it was pointed out in Slack. For future reference, posting Box-related questions over in the Ortus Community forum will make them less likely to get missed (though I do follow both forums)

server-wide REST handler via CommandBox in server.json

Yep, this works fine, but to be clear it doesn’t create any config in the actual Lucee admin. It simply maps the URLs in the servlet so they are processed by Lucee’s REST servlet. So this just gets the request routed into Lucee’s REST bits.

is there a way to configure the REST mappings that doesn’t involve copying/editing lucee-web.xml or going into the Administrator page?

No, at least not that I know of unless there is some Application.cfc support for it. There’s no reason not to add support into CFConfig for REST mappings-- this is what routes the REST request to the actual CFC in your source code. The only reasons REST mappings have never been added to CFConfig are:

  • I don’t use built in REST myself (ColdBox MVC FTW!)
  • No one has offered to sponsor the development of the feature
  • No one has sent a pull request to add support for it

I love pull requests and many people have helped add the missing bits in CFConfig they want to see supported so I’d love to help you do that if you’re still interested.

It’s also worth noting “REST mappings” have no relation to “CF Mappings” outside of the fact they both use the word “mapping” in their name for whatever reason :slight_smile: