@@ -39,6 +39,7 @@ and [old][Old Architecture] RN architectures.
39
39
[ OLD-README.md ] : https://github.com/birdofpreyru/react-native-static-server/blob/master/OLD-README.md
40
40
[ getDeviceType() ] : https://www.npmjs.com/package/react-native-device-info#getDeviceType
41
41
[ MainBundlePath ] : https://www.npmjs.com/package/@dr.pogodin/react-native-fs#mainbundlepath
42
+ [ mod_alias ] : https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_alias
42
43
[ mod_webdav ] : https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_webdav
43
44
[ react-native-device-info ] : https://www.npmjs.com/package/react-native-device-info
44
45
[ react-native-fs ] : https://www.npmjs.com/package/react-native-fs
@@ -50,6 +51,7 @@ and [old][Old Architecture] RN architectures.
50
51
51
52
- [ Getting Started] ( #getting-started )
52
53
- [ Bundling-in Server Assets Into an App Statically] ( #bundling-in-server-assets-into-an-app-statically )
54
+ - [ Enabling Alias module]
53
55
- [ Enabling WebDAV module]
54
56
- [ API Reference] ( #api-reference )
55
57
- [ Project History and Roadmap] ( #project-history-and-roadmap )
@@ -340,6 +342,20 @@ outside platform-specific sub-folders.
340
342
< /Target>
341
343
` ` `
342
344
345
+ # ## Enabling Alias Module
346
+ [Enabling Alias module]: # enabling-alias-module
347
+
348
+ [Lighttpd] module [mod_alias] is used to specify a special document
349
+ root for a given url-subset. To enable it just use ` extraConfig` option of
350
+ [Server] [constructor()] to load and configure it, for example:
351
+
352
+ ` ` ` ts
353
+ extraConfig: `
354
+ server.modules += (" mod_alias" )
355
+ alias.url = (" /sample/url" => " /special/root/path" )
356
+ ` ,
357
+ ` ` `
358
+
343
359
# ## Enabling WebDAV Module
344
360
[Enabling WebDAV module]: # enabling-webdav-module
345
361
@@ -348,15 +364,11 @@ HTTP extensions that provides a framework allowing to create, change, and move
348
364
documents on a server — essentially an easy way to enable ` POST` , ` PUT` ,
349
365
_etc._ functionality for selected routes.
350
366
351
- ** BEWARE:** _As of now, I only need it for implementing a local testing of
352
- network functionality inside [@dr.pogodin/react-native-fs] library, thus for
353
- development needs only, and I have not put efforts to build it with all features
354
- (support of props and locks), and have not looked much into what configuration
355
- is needed for its safe and flexible production use._
367
+ ** BEWARE:** _As of now, props and locks are not supported._
356
368
357
369
To enable [mod_webdav] in the library you need (1) configure your host RN app
358
370
to build Lighttpd with [mod_webdav] included; (2) opt-in to use it for selected
359
- routes when you create [Server] instance inside your TypeScript code .
371
+ routes when you create [Server] instance, using ` extraConfig ` option .
360
372
361
373
1. ** Android** : Edit ` android/gradle.properties` file of your app, adding
362
374
this flag in there:
@@ -374,8 +386,16 @@ routes when you create [Server] instance inside your TypeScript code.
374
386
for [WebDAV] module is always packed with the library, and loaded if opted
375
387
for by [Server]' s [constructor()].
376
388
377
- 2. Use `webdav` option of [Server]' s [constructor()] to enable [WebDAV] for
378
- selected routes of the created server instance.
389
+ 2. Use `extraConfig` option of [Server]' s [constructor()] to load [mod_webdav]
390
+ and use it for selected routes of the created server instance, for example:
391
+ ` ` ` ts
392
+ extraConfig: `
393
+ server.modules += (" mod_webdav" )
394
+ $HTTP [" url" ] =~ " ^/dav/($|/)" {
395
+ webdav.activate = " enable"
396
+ }
397
+ ` ,
398
+ ` ` `
379
399
380
400
# # API Reference
381
401
- [Server] & mdash; Represents a server instance.
@@ -452,6 +472,12 @@ within `options` argument:
452
472
** BEWARE:** If you opt for file logging with this option, it is up to you
453
473
to control and purge the [ERROR_LOG_FILE] as needed.
454
474
475
+ - ` extraConfig` & mdash; ** string** & mdash; Optional. If given, it should be
476
+ a valid piece of
477
+ [Lighttpd configuration](https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration),
478
+ and it will be appended to the base Lighttpd config generated by this
479
+ library according to the other server options.
480
+
455
481
- ` hostname` & mdash; ** string** & mdash; Optional. Sets the address for server
456
482
to bind to.
457
483
- By default, when ` nonLocal` option is ** false** , ` hostname` is set equal
@@ -502,20 +528,9 @@ within `options` argument:
502
528
` details` values set equal " _App entered background_" ,
503
529
and " _App entered foreground_" strings.
504
530
505
- - ` webdav` & mdash; ** string[]** & mdash; Optional. Enables [WebDAV] for specified
506
- server routes. To use this option, first read [Enabling WebDAV module]. Each
507
- string inside provided ` webdav` array is expected to be a Perl-style regular
508
- expression for the route(s) on which [WebDAV] should be enabled. For example,
509
- to enable [WebDAV] for ` /dav` directory and everything below it, you should
510
- give ` webdav = [" ^/dav($|/)" ]` , which will add the following configuration
511
- to the internal [Lighttpd] config of the server:
512
- ` ` ` perl
513
- $HTTP [" url" ] =~ " ^/dav($|/)" {
514
- webdav.activate = " enable"
515
- }
516
- ` ` `
517
- As of now, we don' t yet support more advanced features and configurations for
518
- [mod_webdav].
531
+ - ** DEPRECATED** : ` webdav` & mdash; ** string[]** & mdash; It still works, but it
532
+ will be removed in future versions. Instead of it use ` extraConfig` option to
533
+ enable and configure [WebDAV] as necessary (see [Enabling WebDAV module]).
519
534
520
535
#### .addStateListener()
521
536
[.addStateListener()]: # addstatelistener
0 commit comments