but it doesnt work. i get a 404 error when trying /rest/ instead of getting list of endpoints. this is my endpoint cfc script:
component rest=“true” restpath=“/test” {
in my Application.cfc:
public boolean function onApplicationStart() {
if (directoryExists(expandPath(“/api”))) {
restInitApplication(
dirPath=expandPath(“/api”),
serviceMapping=“api”,
default=true,
password=“abc123”
);
}
return true;
}
in my server.json i have this:
“app”:{
“cfengine”:“lucee@7”,
“restMappings”:“/rest/*”
},
when i add restMappings and try to access a cfc file in the /rest/ path i get “no rest service for [/test/test.cfc] found”.
does the rest mapping work after you load a normal page which loads the application.cfc, rest services via restInitMapping only work after the application.cfc is executed, before that, the config simply isn’t loaded
The only thing I would note with your code is since you are initializing the REST endpoint on the application start – make sure you are actually starting the application.
I have a few apps that sit out there that are static pages with REST endpoints. Often times, the REST endpoints will get hit before the static pages do. Doing that will result in a 404 error because the REST app wasn’t initialized first. Most of my apps are on Docker, so adding a healthcheck parameter on the docker/k8 config that just hits a blank .cfm page is enough to init the app and keep it warm, so the REST endpoints init properly.