Skip to content

Commit

Permalink
feat: adapt to harmonyOS Next (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
wh-hujinyun authored Jul 22, 2024
1 parent a6c2c70 commit 10143e1
Show file tree
Hide file tree
Showing 75 changed files with 701 additions and 7,636 deletions.
20 changes: 20 additions & 0 deletions LICENSE
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.
63 changes: 9 additions & 54 deletions README.md
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();
}

```
40 changes: 0 additions & 40 deletions android/build.gradle

This file was deleted.

6 changes: 0 additions & 6 deletions android/src/main/AndroidManifest.xml

This file was deleted.

92 changes: 0 additions & 92 deletions android/src/main/java/me/alwx/HttpServer/HttpServerModule.java

This file was deleted.

This file was deleted.

88 changes: 0 additions & 88 deletions android/src/main/java/me/alwx/HttpServer/Server.java

This file was deleted.

Binary file added harmony/http_bridge.har
Binary file not shown.
6 changes: 6 additions & 0 deletions harmony/http_bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
17 changes: 17 additions & 0 deletions harmony/http_bridge/BuildProfile.ets
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;
}
Loading

0 comments on commit 10143e1

Please sign in to comment.