-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API endpoint for extensions and modules (#330)
* introduce a http api endpoint for extensions and modules * merge handling of routes into single handler * deprecated old api * remove deprecations * add system module * fix handler * add content handler * api versioning endpoint for navigation tree deactivate api by default and make it activatable for site * load content Nodes * update navigation api, add links to content and frontend * disable the system api endpoints until it is better specified --------- Co-authored-by: Thorsten Marx <[email protected]>
- Loading branch information
Showing
33 changed files
with
886 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
cms-api/src/main/java/com/condation/cms/api/extensions/http/APIHandlerExtensionPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.condation.cms.api.extensions.http; | ||
|
||
/*- | ||
* #%L | ||
* cms-api | ||
* %% | ||
* Copyright (C) 2023 - 2024 CondationCMS | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
import com.condation.cms.api.extensions.AbstractExtensionPoint; | ||
|
||
public abstract class APIHandlerExtensionPoint extends AbstractExtensionPoint { | ||
abstract public PathMapping getMapping(); | ||
} |
36 changes: 36 additions & 0 deletions
36
cms-api/src/main/java/com/condation/cms/api/extensions/http/HttpHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.condation.cms.api.extensions.http; | ||
|
||
/*- | ||
* #%L | ||
* cms-api | ||
* %% | ||
* Copyright (C) 2023 - 2024 CondationCMS | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Response; | ||
import org.eclipse.jetty.util.Callback; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
public interface HttpHandler { | ||
|
||
boolean handle (Request request, Response response, Callback callback) throws Exception; | ||
} |
51 changes: 51 additions & 0 deletions
51
cms-api/src/main/java/com/condation/cms/api/extensions/http/PathMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.condation.cms.api.extensions.http; | ||
|
||
/*- | ||
* #%L | ||
* cms-api | ||
* %% | ||
* Copyright (C) 2023 - 2024 CondationCMS | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.jetty.http.pathmap.PathSpec; | ||
|
||
public class PathMapping { | ||
|
||
private List<Mapping> mappings; | ||
|
||
public PathMapping () { | ||
mappings = new ArrayList<>(); | ||
} | ||
|
||
public void add (PathSpec pathSpec, String method, HttpHandler handler) { | ||
mappings.add(new Mapping(pathSpec, method, handler)); | ||
} | ||
|
||
public Optional<HttpHandler> getMatchingHandler (String uri, String method) { | ||
return mappings.stream().filter(entry -> | ||
entry.pathSpec.matches(uri) && entry.method.equalsIgnoreCase(method) | ||
).map(entry -> entry.handler).findFirst(); | ||
} | ||
|
||
|
||
private static record Mapping (PathSpec pathSpec, String method, HttpHandler handler){}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.