Skip to content

Commit

Permalink
Merge branch 'dev-0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Oct 9, 2023
2 parents 88f0ff4 + 6189ae5 commit 142eded
Show file tree
Hide file tree
Showing 26 changed files with 1,218 additions and 2,824 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ set(PKG_CONFIG_ARGN --libs-only-l)
add_subdirectory(lighttpd1.4)

set(PLUGIN_STATIC
PLUGIN_INIT(mod_alias)\n
PLUGIN_INIT(mod_dirlisting)\n
PLUGIN_INIT(mod_h2)\n
PLUGIN_INIT(mod_indexfile)\n
Expand Down
59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and [old][Old Architecture] RN architectures.
[OLD-README.md]: https://github.com/birdofpreyru/react-native-static-server/blob/master/OLD-README.md
[getDeviceType()]: https://www.npmjs.com/package/react-native-device-info#getDeviceType
[MainBundlePath]: https://www.npmjs.com/package/@dr.pogodin/react-native-fs#mainbundlepath
[mod_alias]: https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_alias
[mod_webdav]: https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_webdav
[react-native-device-info]: https://www.npmjs.com/package/react-native-device-info
[react-native-fs]: https://www.npmjs.com/package/react-native-fs
Expand All @@ -50,6 +51,7 @@ and [old][Old Architecture] RN architectures.

- [Getting Started](#getting-started)
- [Bundling-in Server Assets Into an App Statically](#bundling-in-server-assets-into-an-app-statically)
- [Enabling Alias module]
- [Enabling WebDAV module]
- [API Reference](#api-reference)
- [Project History and Roadmap](#project-history-and-roadmap)
Expand Down Expand Up @@ -340,6 +342,20 @@ outside platform-specific sub-folders.
</Target>
```
### Enabling Alias Module
[Enabling Alias module]: #enabling-alias-module
[Lighttpd] module [mod_alias] is used to specify a special document
root for a given url-subset. To enable it just use `extraConfig` option of
[Server] [constructor()] to load and configure it, for example:
```ts
extraConfig: `
server.modules += ("mod_alias")
alias.url = ("/sample/url" => "/special/root/path")
`,
```
### Enabling WebDAV Module
[Enabling WebDAV module]: #enabling-webdav-module
Expand All @@ -348,15 +364,11 @@ HTTP extensions that provides a framework allowing to create, change, and move
documents on a server &mdash; essentially an easy way to enable `POST`, `PUT`,
_etc._ functionality for selected routes.
**BEWARE:** _As of now, I only need it for implementing a local testing of
network functionality inside [@dr.pogodin/react-native-fs] library, thus for
development needs only, and I have not put efforts to build it with all features
(support of props and locks), and have not looked much into what configuration
is needed for its safe and flexible production use._
**BEWARE:** _As of now, props and locks are not supported._
To enable [mod_webdav] in the library you need (1) configure your host RN app
to build Lighttpd with [mod_webdav] included; (2) opt-in to use it for selected
routes when you create [Server] instance inside your TypeScript code.
routes when you create [Server] instance, using `extraConfig` option.
1. **Android**: Edit `android/gradle.properties` file of your app, adding
this flag in there:
Expand All @@ -374,8 +386,16 @@ routes when you create [Server] instance inside your TypeScript code.
for [WebDAV] module is always packed with the library, and loaded if opted
for by [Server]'s [constructor()].
2. Use `webdav` option of [Server]'s [constructor()] to enable [WebDAV] for
selected routes of the created server instance.
2. Use `extraConfig` option of [Server]'s [constructor()] to load [mod_webdav]
and use it for selected routes of the created server instance, for example:
```ts
extraConfig: `
server.modules += ("mod_webdav")
$HTTP["url"] =~ "^/dav/($|/)" {
webdav.activate = "enable"
}
`,
```
## API Reference
- [Server] &mdash; Represents a server instance.
Expand Down Expand Up @@ -452,6 +472,12 @@ within `options` argument:
**BEWARE:** If you opt for file logging with this option, it is up to you
to control and purge the [ERROR_LOG_FILE] as needed.
- `extraConfig` &mdash; **string** &mdash; Optional. If given, it should be
a valid piece of
[Lighttpd configuration](https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration),
and it will be appended to the base Lighttpd config generated by this
library according to the other server options.
- `hostname` &mdash; **string** &mdash; Optional. Sets the address for server
to bind to.
- By default, when `nonLocal` option is **false**, `hostname` is set equal
Expand Down Expand Up @@ -502,20 +528,9 @@ within `options` argument:
`details` values set equal "_App entered background_",
and "_App entered foreground_" strings.
- `webdav` &mdash; **string[]** &mdash; Optional. Enables [WebDAV] for specified
server routes. To use this option, first read [Enabling WebDAV module]. Each
string inside provided `webdav` array is expected to be a Perl-style regular
expression for the route(s) on which [WebDAV] should be enabled. For example,
to enable [WebDAV] for `/dav` directory and everything below it, you should
give `webdav = ["^/dav($|/)"]`, which will add the following configuration
to the internal [Lighttpd] config of the server:
```perl
$HTTP["url"] =~ "^/dav($|/)" {
webdav.activate = "enable"
}
```
As of now, we don't yet support more advanced features and configurations for
[mod_webdav].
- **DEPRECATED**: `webdav` &mdash; **string[]** &mdash; It still works, but it
will be removed in future versions. Instead of it use `extraConfig` option to
enable and configure [WebDAV] as necessary (see [Enabling WebDAV module]).
#### .addStateListener()
[.addStateListener()]: #addstatelistener
Expand Down
2 changes: 1 addition & 1 deletion dr-pogodin-react-native-static-server.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => "11.0" }
s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/birdofpreyru/react-native-static-server.git", :tag => "#{s.version}" }

s.preserve_paths = 'README.md', 'package.json', 'index.js'
Expand Down
Loading

0 comments on commit 142eded

Please sign in to comment.