[mod] web inf

This commit is contained in:
Andy Bunce 2022-05-11 12:17:30 +01:00
parent 25e0bbf64c
commit 046e4900a7
4 changed files with 234 additions and 8 deletions

View file

@ -1,8 +0,0 @@
# .gitignore sample
###################
# Ignore all files in this dir...
*
# ... except for this one.
!.gitignore

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- Default connector. The Jetty stop port can be specified
in the .basex or pom.xml configuration file. -->
<Call name="addConnector">
<Arg>
<New id="httpConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server"/></Arg>
<Set name="host">0.0.0.0</Set>
<Set name="port">8984</Set>
<Set name="idleTimeout">60000</Set>
<Set name="reuseAddress">true</Set>
</New>
</Arg>
</Call>
</Configure>

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>BaseX: The XML Database and XQuery Processor</display-name>
<description>HTTP Services</description>
<!-- A BaseX option can be overwritten by prefixing the key with "org.basex."
and specifying it in <context-param/> elements, as shown below.
Check out https://docs.basex.org/wiki/Options for a list of all options.
<context-param>
<param-name>org.basex.restxqpath</param-name>
<param-value>.</param-value>
</context-param>
<context-param>
<param-name>org.basex.dbpath</param-name>
<param-value>WEB-INF/data</param-value>
</context-param>
<context-param>
<param-name>org.basex.repopath</param-name>
<param-value>WEB-INF/repo</param-value>
</context-param>
<context-param>
<param-name>org.basex.user</param-name>
<param-value>admin</param-value>
</context-param>
<context-param>
<param-name>org.basex.authmethod</param-name>
<param-value>Digest</param-value>
</context-param>
<context-param>
<param-name>org.basex.httplocal</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.basex.timeout</param-name>
<param-value>5</param-value>
</context-param>
<context-param>
<param-name>org.basex.log</param-name>
<param-value>false</param-value>
</context-param>
-->
<!-- Global session and servlet listener -->
<listener>
<listener-class>org.basex.http.SessionListener</listener-class>
</listener>
<listener>
<listener-class>org.basex.http.ServletListener</listener-class>
</listener>
<!-- CORS in Jetty: Access-Control-Allow-Origin: *
<filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
<init-param>
<param-name>allowedOrigins</param-name>
<param-value>*</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<!-- RESTXQ Service (can be disabled by removing this entry) -->
<servlet>
<servlet-name>RESTXQ</servlet-name>
<servlet-class>org.basex.http.restxq.RestXqServlet</servlet-class>
<init-param>
<param-name>org.basex.user</param-name>
<param-value>admin</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RESTXQ</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- WebSocket Service (can be disabled by removing this entry) -->
<servlet>
<servlet-name>WebSocket</servlet-name>
<servlet-class>org.basex.http.ws.WsServlet</servlet-class>
<!-- Limits of the WebSocket connection
<init-param>
<param-name>maxIdleTime</param-name>
<param-value>100000</param-value>
</init-param>
<init-param>
<param-name>maxTextMessageSize</param-name>
<param-value>3000</param-value>
</init-param>
<init-param>
<param-name>maxBinaryMessageSize </param-name>
<param-value>3000</param-value>
</init-param>
-->
</servlet>
<servlet-mapping>
<servlet-name>WebSocket</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<!-- REST Service (can be disabled by removing this entry) -->
<servlet>
<servlet-name>REST</servlet-name>
<servlet-class>org.basex.http.rest.RESTServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>REST</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!-- WebDAV Service (can be disabled by removing this entry) -->
<servlet>
<servlet-name>WebDAV</servlet-name>
<servlet-class>org.basex.http.webdav.WebDAVServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WebDAV</servlet-name>
<url-pattern>/webdav/*</url-pattern>
</servlet-mapping>
<!-- Mapping for static resources (may be restricted to a sub path) -->
<servlet>
<servlet-name>default</servlet-name>
<init-param>
<param-name>useFileMappedBuffer</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
</web-app>

69
basex/webapp/restxq.xqm Normal file
View file

@ -0,0 +1,69 @@
(:~
: This module contains some basic examples for RESTXQ annotations.
: @author BaseX Team
:)
module namespace page = 'http://basex.org/examples/web-page';
(:~
: Generates a welcome page.
: @return HTML page
:)
declare
%rest:GET
%rest:path('')
%output:method('xhtml')
%output:omit-xml-declaration('no')
%output:doctype-public('-//W3C//DTD XHTML 1.0 Transitional//EN')
%output:doctype-system('http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')
function page:start(
) as element(Q{http://www.w3.org/1999/xhtml}html) {
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>BaseX HTTP Services</title>
<link rel='stylesheet' type='text/css' href='static/style.css'/>
</head>
<body>
<div class='right'><a href='/'><img src='static/basex.svg'/></a></div>
<h1>BaseX HTTP Services</h1>
<div>Welcome to the BaseX HTTP Services. They allow you to:</div>
<ul>
<li>create web applications and services with
<a href='https://docs.basex.org/wiki/RESTXQ'>RESTXQ</a>,</li>
<li>use full-duplex communication with
<a href='https://docs.basex.org/wiki/WebSockets'>WebSockets</a>,</li>
<li>query and modify databases via <a href='https://docs.basex.org/wiki/REST'>REST</a>
(try <a href='rest'>here</a>), and</li>
<li>browse and update resources via
<a href='https://docs.basex.org/wiki/WebDAV'>WebDAV</a>.</li>
</ul>
<p>Find more information on the
<a href='https://docs.basex.org/wiki/Web_Application'>Web Application</a>
page in our documentation.</p>
<p>The following sample applications give you a glimpse of how applications
can be written with BaseX:</p>
<h3><a href='dba'>DBA: Database Administration</a></h3>
<p>The Database Administration interface is completely
written in RESTXQ.<br/>
The source code helps to understand how complex
web applications can be built with XQuery.
</p>
<h3><a href='chat'>WebSocket Chat</a></h3>
<p>The chat application demonstrates how bidirectional communication
is realized with BaseX.<br/>
For a better experience when testing the chat,
consider the following steps:
</p>
<ol>
<li> Create different database users first (e.g. via the DBA).</li>
<li> Open two different browsers and log in with different users.</li>
</ol>
</body>
</html>
};