Hi, I'd like to serve static content in the same server as the one handling the restxq. However, I noticed it expects the content to be in some level under the static directory. Then, the URL also needs the static directory.
Is it possible to change both the directory the static files live and the URL? That way I can create a site without requiring the end user to append static to the URL to get to index.html.
Ultimately, I want to create static pages, restxq services, schemas and a database, but have them isolated from the BaseX distribution. I've seen some flags to specify some directory locations, but not the static one.
I'm using Ant so I can take the source distribution, copy that to a target directory, and in another step, copy my source files. I realize Ant is old, but I have no idea how to do this in Maven.
By the way, I absolutely love how easy it is to do a site yet it actually seems quite powerful.
Kind Regards, Ben
Hi Ben,
Glad you enjoy setting up a restxq project, we use it as a primary driver of our Web-applications 👍
I set up a small project (in response to a related question last week), that serves static content from /webapp at „http://localhost/%E2%80%9C and maps all restxq endpoints to http://localhost/api
=> https://git.basex.io/basex-public/mailinglist-autocomplete This might be a good start for you future endeavors :-)
The relevant settings are found in „.basex“ (This file defines where on disk to look for static and restxq files) and „ webapp/ WEB-INF/ web.xml“ (defines at what path static files and restxq endpoints are served by the Webserver).
These options are explained here https://docs.basex.org/wiki/Options#HTTP_Services and https://docs.basex.org/wiki/Web_Application#Services
You should be fine using ant 🐜
Feel free to ask for more information :-)
Best Michael
Von meinem iPhone gesendet
Am 03.07.2020 um 09:19 schrieb Ben Pracht ben.pracht@gmail.com:
Hi, I'd like to serve static content in the same server as the one handling the restxq. However, I noticed it expects the content to be in some level under the static directory. Then, the URL also needs the static directory.
Is it possible to change both the directory the static files live and the URL? That way I can create a site without requiring the end user to append static to the URL to get to index.html.
Ultimately, I want to create static pages, restxq services, schemas and a database, but have them isolated from the BaseX distribution. I've seen some flags to specify some directory locations, but not the static one.
I'm using Ant so I can take the source distribution, copy that to a target directory, and in another step, copy my source files. I realize Ant is old, but I have no idea how to do this in Maven.
By the way, I absolutely love how easy it is to do a site yet it actually seems quite powerful.
Kind Regards, Ben
Thanks Michael,
I cloned your repo and borrowed your .basex file. It did indeed allow me to specify the page location. However, I'm not able to get it to find my RESTXQ is my services. I added the out of the box BaseX ./bin to my PATH and changed to a completely different directory. Attached is my .basex and database-services.xqm file. For debugging purposes, I wanted to make sure my services point to the right database. My setup is like this:
PROJECT_ROOT/.basex PROJECT_ROOT/.basexhome PROJECT_ROOT/modules/database PROJECT_ROOT/webapp/modules/database-services.xqm PROJECT_ROOT/modules/database-services.xqm
I duplicated the database-services file because I wasn't sure what folder the RESTXQ was relative to.
Vielen Danke!
Best Regards, Ben Pracht 919.809.2439 ben.pracht@gmail.com
On Fri, Jul 3, 2020 at 5:13 PM Michael Seiferle ms@basex.org wrote:
Hi Ben,
Glad you enjoy setting up a restxq project, we use it as a primary driver of our Web-applications 👍
I set up a small project (in response to a related question last week), that serves static content from /webapp at „http://localhost/%E2%80%9C and maps all restxq endpoints to http://localhost/api
=> https://git.basex.io/basex-public/mailinglist-autocomplete This might be a good start for you future endeavors :-)
The relevant settings are found in „.basex“ (This file defines where on disk to look for static and restxq files) and „ webapp https://git.basex.io/basex-public/mailinglist-autocomplete/-/tree/main/webapp / WEB-INF https://git.basex.io/basex-public/mailinglist-autocomplete/-/tree/main/webapp/WEB-INF / *web.xml https://git.basex.io/basex-public/mailinglist-autocomplete/-/blob/main/webapp/WEB-INF/web.xml“ (*defines at what path static files and restxq endpoints are served by the Webserver).
These options are explained here https://docs.basex.org/wiki/Options#HTTP_Services and https://docs.basex.org/wiki/Web_Application#Services
You should be fine using ant 🐜
Feel free to ask for more information :-)
Best Michael
Von meinem iPhone gesendet
Am 03.07.2020 um 09:19 schrieb Ben Pracht ben.pracht@gmail.com:
Hi, I'd like to serve static content in the same server as the one handling the restxq. However, I noticed it expects the content to be in some level under the static directory. Then, the URL also needs the static directory.
Is it possible to change both the directory the static files live and the URL? That way I can create a site without requiring the end user to append static to the URL to get to index.html.
Ultimately, I want to create static pages, restxq services, schemas and a database, but have them isolated from the BaseX distribution. I've seen some flags to specify some directory locations, but not the static one.
I'm using Ant so I can take the source distribution, copy that to a target directory, and in another step, copy my source files. I realize Ant is old, but I have no idea how to do this in Maven.
By the way, I absolutely love how easy it is to do a site yet it actually seems quite powerful.
Kind Regards, Ben
Hi Ben,
Sorry for the belated response — maybe you forgot to update the web.xml file?
RestXQ-Resolution works as follows:
The .basex file configures **where on disk** the RestXQ-Servlet looks für XQuery modules:
The following options can be set:
* WEBPATH
Points to the directory in which all the Web Application https://docs.basex.org/wiki/Web_Application contents are stored, including XQuery, Script, RESTXQ https://docs.basex.org/wiki/RESTXQ and configuration files:
In your case: PROJECT_ROOT/webapp
* RESTXQPATH
If this a relative path, it will be relative to your WEBPATH — so setting it to „modules“ will resolve to: PROJECT_ROOT/webapp/modules
Now this summarizes it for your on disk-context ;-)
Switchting to the Servlet-context, you must make sure to tell the Container where to server your RESTXQ-Servlet: This can be seen in Web.xml here:
https://git.basex.io/basex-public/mailinglist-autocomplete/-/blob/main/webap...
<servlet-mapping> <servlet-name>RESTXQ</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping>
So basically you need to tell jetty, or whatever container you have, what’s the ROOT-Url for the RESTXQ contents. So in my web.xml anything *under* /api/ will be sent to the RESTXQ-Servlet which in turn tries to make sense of the URL and resolve it against your XQuery annotations :-)
Hope this helps
Michael
Am 10.07.2020 um 23:28 schrieb Ben Pracht ben.pracht@gmail.com:
Thanks Michael,
I cloned your repo and borrowed your .basex file. It did indeed allow me to specify the page location. However, I'm not able to get it to find my RESTXQ is my services. I added the out of the box BaseX ./bin to my PATH and changed to a completely different directory. Attached is my .basex and database-services.xqm file. For debugging purposes, I wanted to make sure my services point to the right database. My setup is like this:
PROJECT_ROOT/.basex PROJECT_ROOT/.basexhome PROJECT_ROOT/modules/database PROJECT_ROOT/webapp/modules/database-services.xqm PROJECT_ROOT/modules/database-services.xqm
I duplicated the database-services file because I wasn't sure what folder the RESTXQ was relative to.
Vielen Danke!
Best Regards, Ben Pracht 919.809.2439 ben.pracht@gmail.com mailto:ben.pracht@gmail.com
basex-talk@mailman.uni-konstanz.de