add method getVersionBasePath()

add method preExecute()
This commit is contained in:
2025-05-23 16:21:08 -05:00
parent 09d8aac77f
commit 828a0ed594

View File

@ -49,6 +49,7 @@ import com.kingsrook.qqq.openapi.model.SecurityScheme;
import com.kingsrook.qqq.openapi.model.SecuritySchemeType; import com.kingsrook.qqq.openapi.model.SecuritySchemeType;
import com.kingsrook.qqq.openapi.model.Type; import com.kingsrook.qqq.openapi.model.Type;
import io.javalin.apibuilder.EndpointGroup; import io.javalin.apibuilder.EndpointGroup;
import io.javalin.http.Context;
/******************************************************************************* /*******************************************************************************
@ -82,12 +83,21 @@ public abstract class AbstractMiddlewareVersion
{ {
for(AbstractEndpointSpec<?, ?, ?> spec : CollectionUtils.nonNullList(getEndpointSpecs())) for(AbstractEndpointSpec<?, ?, ?> spec : CollectionUtils.nonNullList(getEndpointSpecs()))
{ {
spec.defineRoute("/" + getVersion() + "/"); spec.defineRoute(this, getVersionBasePath());
} }
}); });
} }
/***************************************************************************
**
***************************************************************************/
public String getVersionBasePath()
{
return ("/" + getVersion() + "/");
}
/*************************************************************************** /***************************************************************************
** For initial setup when server boots, set the qInstance - but also, ** For initial setup when server boots, set the qInstance - but also,
@ -123,7 +133,7 @@ public abstract class AbstractMiddlewareVersion
for(AbstractEndpointSpec<?, ?, ?> spec : list) for(AbstractEndpointSpec<?, ?, ?> spec : list)
{ {
CompleteOperation completeOperation = spec.defineCompleteOperation(); CompleteOperation completeOperation = spec.defineCompleteOperation();
String fullPath = ("/" + basePath + "/" + getVersion() + "/" + completeOperation.getPath()).replaceAll("/+", "/"); String fullPath = ("/" + basePath + getVersionBasePath() + completeOperation.getPath()).replaceAll("/+", "/");
Path path = paths.computeIfAbsent(fullPath, (k) -> new Path()); Path path = paths.computeIfAbsent(fullPath, (k) -> new Path());
Method method = completeOperation.getMethod(); Method method = completeOperation.getMethod();
@ -358,4 +368,16 @@ public abstract class AbstractMiddlewareVersion
LOG.warn("More than one endpoint spec for version " + getVersion() + " defined a " + completeOperation.getHttpMethod() + " at path: " + completeOperation.getPath() + ". The last one encountered (from " + spec.getClass().getSimpleName() + ") will be used."); LOG.warn("More than one endpoint spec for version " + getVersion() + " defined a " + completeOperation.getHttpMethod() + " at path: " + completeOperation.getPath() + ". The last one encountered (from " + spec.getClass().getSimpleName() + ") will be used.");
} }
} }
/***************************************************************************
**
***************************************************************************/
public void preExecute(Context context)
{
/////////////////////
// noop at default //
/////////////////////
}
} }