Skip to content

Commit 54300bd

Browse files
committed
Merge branch 'dev-0.9'
2 parents 00100ac + a2e059a commit 54300bd

File tree

11 files changed

+2440
-872
lines changed

11 files changed

+2440
-872
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ set(PLUGIN_STATIC
120120
PLUGIN_INIT(mod_dirlisting)\n
121121
PLUGIN_INIT(mod_h2)\n
122122
PLUGIN_INIT(mod_indexfile)\n
123+
PLUGIN_INIT(mod_rewrite)\n
123124
PLUGIN_INIT(mod_staticfile)\n
124125
)
125126

README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and [old][Old Architecture] RN architectures.
4040
[getDeviceType()]: https://www.npmjs.com/package/react-native-device-info#getDeviceType
4141
[MainBundlePath]: https://www.npmjs.com/package/@dr.pogodin/react-native-fs#mainbundlepath
4242
[mod_alias]: https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_alias
43+
[mod_rewrite]: https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_rewrite
4344
[mod_webdav]: https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_webdav
4445
[react-native-device-info]: https://www.npmjs.com/package/react-native-device-info
4546
[react-native-fs]: https://www.npmjs.com/package/react-native-fs
@@ -50,8 +51,9 @@ and [old][Old Architecture] RN architectures.
5051
## Content
5152

5253
- [Getting Started](#getting-started)
53-
- [Bundling-in Server Assets Into an App Statically](#bundling-in-server-assets-into-an-app-statically)
54+
- [Bundling-in Server Assets Into an App Statically]
5455
- [Enabling Alias module]
56+
- [Enabling Rewrite module]
5557
- [Enabling WebDAV module]
5658
- [API Reference](#api-reference)
5759
- [Project History and Roadmap](#project-history-and-roadmap)
@@ -219,6 +221,7 @@ and [old][Old Architecture] RN architectures.
219221
```
220222
221223
### Bundling-in Server Assets Into an App Statically
224+
[Bundling-in Server Assets Into an App Statically]: #bundling-in-server-assets-into-an-app-statically
222225
223226
The assets to be served by the server may come to the target device in different
224227
ways, for example, they may be generated during the app's runtime, or downloaded
@@ -360,10 +363,29 @@ root for a given url-subset. To enable it just use `extraConfig` option of
360363
[Server] [constructor()] to load and configure it, for example:
361364
362365
```ts
363-
extraConfig: `
364-
server.modules += ("mod_alias")
365-
alias.url = ("/sample/url" => "/special/root/path")
366-
`,
366+
extraConfig: `
367+
server.modules += ("mod_alias")
368+
alias.url = ("/sample/url" => "/special/root/path")
369+
`,
370+
```
371+
372+
### Enabling Rewrite Module
373+
[Enabling Rewrite module]: #enabling-rewrite-module
374+
375+
[Lighttpd]'s module [mod_rewrite] can be used for interal redirects,
376+
URL rewrites by the server. To enable it just use `extraConfig` option of
377+
[Server] [constructor()] to load and configure it, for example:
378+
379+
```ts
380+
extraConfig: `
381+
server.modules += ("mod_rewrite")
382+
url.rewrite-once = ("/some/path/(.*)" => "/$1")
383+
`,
384+
385+
// With such configuration, for example, a request
386+
// GET "/some/path/file"
387+
// will be redirected to
388+
// GET "/file"
367389
```
368390
369391
### Enabling WebDAV Module
@@ -376,6 +398,15 @@ _etc._ functionality for selected routes.
376398
377399
**BEWARE:** _As of now, props and locks are not supported._
378400
401+
**BEWARE:** _If you have set up the server to serve static assets bundled into
402+
the app, the chances are your server works with a readonly location on most
403+
platforms (in the case of Android it is anyway necessary to unpack bundled
404+
assets to the regular filesystem, thus there the server might be serving
405+
from a writeable location already). The easiest way around it is to use
406+
[mod_alias][Enabling Alias module] to point URLs configured for [mod_webdav]
407+
to a writeable filesystem location, different from that of the served static
408+
assets._
409+
379410
To enable [mod_webdav] in the library you need (1) configure your host RN app
380411
to build Lighttpd with [mod_webdav] included; (2) opt-in to use it for selected
381412
routes when you create [Server] instance, using `extraConfig` option.

dr-pogodin-react-native-static-server.podspec

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@ Pod::Spec.new do |s|
6060
:script => <<-CMD
6161
set -e
6262
63+
if [[ ${CONFIGURATION} == "Debug" ]]
64+
then
65+
LIGHTTPD_CONFIG="Debug"
66+
else
67+
LIGHTTPD_CONFIG="Release"
68+
fi
69+
6370
if [[ ${PLATFORM_FAMILY_NAME} == "iOS" ]]
6471
then
6572
EXTRA_CONFIG_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=${IPHONEOS_DEPLOYMENT_TARGET} -DCMAKE_SYSTEM_NAME=iOS -GXcode"
66-
BUILD_OUTPUT_FOLDER_LIGHTTPD="/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}"
73+
BUILD_OUTPUT_FOLDER_LIGHTTPD="/${LIGHTTPD_CONFIG}${EFFECTIVE_PLATFORM_NAME}"
6774
BUILD_OUTPUT_FOLDER_PCRE2="/Release${EFFECTIVE_PLATFORM_NAME}"
6875
else
6976
# This assumes Mac Catalyst build.
@@ -73,7 +80,7 @@ Pod::Spec.new do |s|
7380
cmake ${PODS_TARGET_SRCROOT} -B ${TARGET_TEMP_DIR} \
7481
-DBUILD_STATIC=1 -DBUILD_LIBRARY=1 ${EXTRA_CONFIG_ARGS} #{$extraCMakeArgs}
7582
76-
cmake --build ${TARGET_TEMP_DIR} --config ${CONFIGURATION} --target lighttpd
83+
cmake --build ${TARGET_TEMP_DIR} --config ${LIGHTTPD_CONFIG} --target lighttpd
7784
7885
cp ${TARGET_TEMP_DIR}/lighttpd1.4/build${BUILD_OUTPUT_FOLDER_LIGHTTPD}/*.a \
7986
${TARGET_TEMP_DIR}/pcre2${BUILD_OUTPUT_FOLDER_PCRE2}/*.a \

0 commit comments

Comments
 (0)