From 10d743605104732c9ca995b3462a351e689cf2be Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Sat, 11 Jun 2016 00:33:02 -0400 Subject: [PATCH] add HTTPD plugin --- src/index.ts | 3 +++ src/plugins/httpd.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/plugins/httpd.ts diff --git a/src/index.ts b/src/index.ts index e7546147..68e4b0c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,6 +42,7 @@ import {GooglePlus} from './plugins/google-plus'; import {GoogleMap} from './plugins/googlemaps'; import {GoogleAnalytics} from './plugins/googleanalytics'; import {Hotspot} from './plugins/hotspot'; +import {Httpd} from './plugins/httpd'; import {ImagePicker} from './plugins/imagepicker'; import {InAppBrowser} from './plugins/inappbrowser'; import {Insomnia} from './plugins/insomnia'; @@ -66,6 +67,7 @@ import {Vibration} from './plugins/vibration'; import {WebIntent} from './plugins/webintent'; export * from './plugins/googlemaps'; export * from './plugins/3dtouch'; +export * from './plugins/httpd'; export { ActionSheet, AdMob, @@ -169,6 +171,7 @@ window['IonicNative'] = { GoogleMap : GoogleMap, GoogleAnalytics: GoogleAnalytics, Hotspot: Hotspot, + Httpd: Httpd, ImagePicker: ImagePicker, InAppBrowser: InAppBrowser, Keyboard: Keyboard, diff --git a/src/plugins/httpd.ts b/src/plugins/httpd.ts new file mode 100644 index 00000000..2c29bfdc --- /dev/null +++ b/src/plugins/httpd.ts @@ -0,0 +1,57 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from 'rxjs/Observable'; +/** + * @name Httpd + * @description + * Embedded httpd for Cordova apps. Light weight HTTP server. + */ +@Plugin({ + plugin: 'https://github.com/floatinghotpot/cordova-httpd.git', + pluginRef: 'CorHttpd', + repo: 'https://github.com/floatinghotpot/cordova-httpd', + platforms: ['iOS', 'Android'] +}) +export class Httpd { + + /** + * Starts a web server. + * @returns {Observable} Returns an Observable. Subscribe to receive the URL for your web server (if succeeded). Unsubscribe to stop the server. + * @param options {HttpdOptions} + */ + @Cordova({ + observable: true, + clearFunction: 'stopServer' + }) + static startServer(options: any): Observable {return; } + + /** + * Gets the URL of the running server + * @returns {Promise} Returns a promise that resolves with the URL of the web server. + */ + @Cordova() + static getUrl(): Promise {return; } + + /** + * Get the local path of the running webserver + * @returns {Promise} Returns a promise that resolves with the local path of the web server. + */ + @Cordova() + static getLocalPath(): Promise {return; } +} +/** + * These options are used for the Httpd.startServer() function. + */ +export interface HttpdOptions { + /** + * The public root directory for your web server. + */ + www_root: string; + /** + * The port number to use. + */ + port: number; + /** + * Setting this option to false will allow remote access to your web server (over any IP) + */ + localhost_only: boolean; +} \ No newline at end of file