HTTP server for React Native
Go to file
alwx 64b37fe7e5 0.4.0: HTTP responses, everything is ready for status-dev-cli feature/responses-support 2017-05-22 14:25:19 +03:00
android 0.4.0: HTTP responses, everything is ready for status-dev-cli feature/responses-support 2017-05-22 14:25:19 +03:00
ios 0.4.0: HTTP responses, everything is ready for status-dev-cli feature/responses-support 2017-05-22 14:25:19 +03:00
.gitignore 0.4.0: HTTP responses, everything is ready for status-dev-cli feature/responses-support 2017-05-22 14:25:19 +03:00
README.md iOS module, fixes 2017-02-07 14:03:16 +03:00
httpServer.js 0.4.0: HTTP responses, everything is ready for status-dev-cli feature/responses-support 2017-05-22 14:25:19 +03:00
package.json 0.4.0: HTTP responses, everything is ready for status-dev-cli feature/responses-support 2017-05-22 14:25:19 +03:00

README.md

react-native-http-bridge

HTTP Server for React Native

Supports only POST-requests and one-way communication. Created for Status.im

Install

npm install --save react-native-http-bridge

With React Native 0.27+

react-native link react-native-http-bridge

Example

First import/require react-native-http-server:


    var httpBridge = require('react-native-http-bridge');

Initalise the server in the componentWillMount lifecycle method. You need to provide a port and a callback where requests will be captured. Currently there is no way to return responses.


    componentWillMount(){

      // initalize the server (now accessible via localhost:1234)
      httpBridge.start(5561, function(request) {

          // request.url
          // request.postData

      });

    }

Finally, ensure that you disable the server when your component is being unmounted.


  componentWillUnmount() {
    httpBridge.stop();
  }