forked from alwx/react-native-http-bridge
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6c2c70
commit 10143e1
Showing
75 changed files
with
701 additions
and
7,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
Copyright © 2024 <copyright holders> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the “Software”), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,20 @@ | ||
# react-native-http-bridge | ||
# @react-native-oh-tpl/react-native-haptic-feedback | ||
|
||
Simple HTTP server for [React Native](https://github.com/facebook/react-native). | ||
Created for [Status.im](https://github.com/status-im/status-react). | ||
本项目基于 [react-native-http-bridge](https://github.com/alwx/react-native-http-bridge) | ||
|
||
Since 0.5.0 supports and handles GET, POST, PUT and DELETE requests. | ||
The library can be useful for handling requests with `application/json` content type | ||
(and this is the only content type we support at the current stage) and returning different responses. | ||
## 文档地址 / Documentation URL | ||
|
||
Since 0.6.0 can handle millions of requests at the same time and also includes some very basic support for [React Native QT](https://github.com/status-im/react-native-desktop). | ||
[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-haptic-feedback.md) | ||
|
||
## Install | ||
[英文 / English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-en/react-native-haptic-feedback.md) | ||
|
||
```shell | ||
npm install --save react-native-http-bridge | ||
``` | ||
## Codegen | ||
|
||
## Automatically link | ||
该库已接入 codegen,具体请查阅文档。 | ||
|
||
#### With React Native 0.27+ | ||
|
||
```shell | ||
react-native link react-native-http-bridge | ||
``` | ||
## 请悉知 / Acknowledgements | ||
|
||
## Example | ||
本项目基于 [The MIT License (MIT)](https://www.mit-license.org/) ,请自由地享受和参与开源。 | ||
|
||
First import/require react-native-http-server: | ||
|
||
```js | ||
|
||
var httpBridge = require('react-native-http-bridge'); | ||
|
||
``` | ||
|
||
|
||
Initalize the server in the `componentWillMount` lifecycle method. You need to provide a `port` and a callback. | ||
|
||
```js | ||
|
||
componentWillMount() { | ||
// initalize the server (now accessible via localhost:1234) | ||
httpBridge.start(5561, 'http_service' request => { | ||
|
||
// you can use request.url, request.type and request.postData here | ||
if (request.type === "GET" && request.url.split("/")[1] === "users") { | ||
httpBridge.respond(request.requestId, 200, "application/json", "{\"message\": \"OK\"}"); | ||
} else { | ||
httpBridge.respond(request.requestId, 400, "application/json", "{\"message\": \"Bad Request\"}"); | ||
} | ||
|
||
}); | ||
} | ||
|
||
``` | ||
|
||
Finally, ensure that you disable the server when your component is being unmounted. | ||
|
||
```js | ||
|
||
componentWillUnmount() { | ||
httpBridge.stop(); | ||
} | ||
|
||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
92 changes: 0 additions & 92 deletions
92
android/src/main/java/me/alwx/HttpServer/HttpServerModule.java
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
android/src/main/java/me/alwx/HttpServer/HttpServerReactPackage.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/node_modules | ||
/oh_modules | ||
/.preview | ||
/build | ||
/.cxx | ||
/.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Use these variables when you tailor your ArkTS code. They must be of the const type. | ||
*/ | ||
export const HAR_VERSION = '0.6.1-0.0.1'; | ||
export const BUILD_MODE_NAME = 'debug'; | ||
export const DEBUG = true; | ||
export const TARGET_NAME = 'default'; | ||
|
||
/** | ||
* BuildProfile Class is used only for compatibility purposes. | ||
*/ | ||
export default class BuildProfile { | ||
static readonly HAR_VERSION = HAR_VERSION; | ||
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; | ||
static readonly DEBUG = DEBUG; | ||
static readonly TARGET_NAME = TARGET_NAME; | ||
} |
Oops, something went wrong.