Skip to content

mandrigin/react-native-http-bridge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Automatically link

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();
  }

About

HTTP server for React Native

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Objective-C 96.8%
  • Java 2.9%
  • JavaScript 0.3%