0.2.8 • Published 2 years ago

react-native-http-server-x v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-http-server-x

Getting started

$ npm install react-native-http-server-x --save

Manual installation

iOS

$ cd ios & pod install

Usage

import { Router, HttpServer } from 'react-native-http-server-x';

const router = new Router('/').get(request => {
  console.log("id", request.id);
  console.log("method", request.method);
  console.log("path", request.path);
  console.log("query", request.query);
  console.log("headers", request.headers);
  console.log("data", request.data);

  return { 
    status: 200, 
    data: JSON.stringify({message: "Hello"}),
    contentType: "application/json"
  };
})

const httpServer = new HttpServer(9100);
httpServer.registerRouter(router);

httpServer.start().then((url) => {
  console.log(`Server running on ${url}`)
  setUrl("http://127.0.0.1:9100?arg=1");
}).catch((err) => {
  console.error(err)
});

Result

LOG  Running "main" with {"rootTag":1,"initialProps":{}}
LOG  Server running on http://192.168.1.250:9100/
LOG  id FE929FBA-A86D-4511-86C9-70516246FC4B
LOG  method GET
LOG  path /
LOG  query {"arg": "1"}
LOG  headers {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "es-US,es-419;q=0.9,es;q=0.8", "Connection": "keep-alive", "Host": "127.0.0.1:9100", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"}
LOG  contentType -1
LOG  contentLength 
LOG  data 
0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago