add HTTPD plugin

This commit is contained in:
Ibrahim Hadeed 2016-06-11 00:33:02 -04:00
parent 2d36c6b812
commit 10d7436051
2 changed files with 60 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import {GooglePlus} from './plugins/google-plus';
import {GoogleMap} from './plugins/googlemaps'; import {GoogleMap} from './plugins/googlemaps';
import {GoogleAnalytics} from './plugins/googleanalytics'; import {GoogleAnalytics} from './plugins/googleanalytics';
import {Hotspot} from './plugins/hotspot'; import {Hotspot} from './plugins/hotspot';
import {Httpd} from './plugins/httpd';
import {ImagePicker} from './plugins/imagepicker'; import {ImagePicker} from './plugins/imagepicker';
import {InAppBrowser} from './plugins/inappbrowser'; import {InAppBrowser} from './plugins/inappbrowser';
import {Insomnia} from './plugins/insomnia'; import {Insomnia} from './plugins/insomnia';
@ -66,6 +67,7 @@ import {Vibration} from './plugins/vibration';
import {WebIntent} from './plugins/webintent'; import {WebIntent} from './plugins/webintent';
export * from './plugins/googlemaps'; export * from './plugins/googlemaps';
export * from './plugins/3dtouch'; export * from './plugins/3dtouch';
export * from './plugins/httpd';
export { export {
ActionSheet, ActionSheet,
AdMob, AdMob,
@ -169,6 +171,7 @@ window['IonicNative'] = {
GoogleMap : GoogleMap, GoogleMap : GoogleMap,
GoogleAnalytics: GoogleAnalytics, GoogleAnalytics: GoogleAnalytics,
Hotspot: Hotspot, Hotspot: Hotspot,
Httpd: Httpd,
ImagePicker: ImagePicker, ImagePicker: ImagePicker,
InAppBrowser: InAppBrowser, InAppBrowser: InAppBrowser,
Keyboard: Keyboard, Keyboard: Keyboard,

57
src/plugins/httpd.ts Normal file
View File

@ -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<string>} 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<string> {return; }
/**
* Gets the URL of the running server
* @returns {Promise<string>} Returns a promise that resolves with the URL of the web server.
*/
@Cordova()
static getUrl(): Promise<string> {return; }
/**
* Get the local path of the running webserver
* @returns {Promise<string>} Returns a promise that resolves with the local path of the web server.
*/
@Cordova()
static getLocalPath(): Promise<string> {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;
}