UNPKG

1.8 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2export interface HttpdOptions {
3 /**
4 * The public root directory for your web server. This path is relative to your app's www directory.
5 * Default is current directory.
6 */
7 www_root?: string;
8 /**
9 * The port number to use.
10 * Default is 8888
11 */
12 port?: number;
13 /**
14 * Setting this option to false will allow remote access to your web server (over any IP).
15 * Default is false.
16 */
17 localhost_only?: boolean;
18}
19/**
20 * @name Httpd
21 * @description
22 * Embedded httpd for Cordova apps. Light weight HTTP server.
23 * @usage
24 * ```typescript
25 * import {Httpd, HttpdOptions} from 'ionic-native';
26 *
27 * let options: HttpdOptions = {
28 * www_root: 'httpd_root', // relative path to app's www directory
29 * port: 80,
30 * localhost_only: false
31 * };
32 *
33 * Httpd.startServer(options).subscribe((data) => {
34 * console.log('Server is live');
35 * });
36 *
37 * ```
38 * @interfaces
39 * HttpdOptions
40 */
41export declare class Httpd {
42 /**
43 * Starts a web server.
44 * @param options {HttpdOptions}
45 * @returns {Observable<string>} Returns an Observable. Subscribe to receive the URL for your web server (if succeeded). Unsubscribe to stop the server.
46 */
47 static startServer(options?: HttpdOptions): Observable<string>;
48 /**
49 * Gets the URL of the running server
50 * @returns {Promise<string>} Returns a promise that resolves with the URL of the web server.
51 */
52 static getUrl(): Promise<string>;
53 /**
54 * Get the local path of the running webserver
55 * @returns {Promise<string>} Returns a promise that resolves with the local path of the web server.
56 */
57 static getLocalPath(): Promise<string>;
58}