aaron-lin/internal-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aaron-lin/internal-api

Composer 安装命令:

composer require aaron-lin/internal-api

包简介

README 文档

README

Introduction

This document describes the internal API of the application. The internal API is used in communication of backend. The internal API is not exposed to the public and is only used by the backend.

Authorization

The followinig API are authorized with Bearer-type tokens. Remote servers must send API key through HTTP header Authorization with Bearer-type token. The API key is generated by backend and is unique for each remote server. The API key is used to identify the remote server. Hashed API keys are stored in file system. The API key is generated by the following command:

$NewApiKey = random_bytes(40);
$HashedApiKey = crypt($newApiKey, 'salt');  //server only stores hashed API key

And the API keys storage file example is here.

1. Client Cache

1.1 Create Cache on Client

POST /iapi/cache

Remote server request server to create cache on server file system.

Request: String in HTTP Header, Parameter(s) in HTTP Body

Header

Name Type Description
Authorization string (Required) Bearer type token,token content is API Key
Authorization: Bearer b01fd1c05d93e77a887fa6c8c91088bb7f053fb220eaf87d51e5efa30fea9d25

Body

Name Type Description
fromDB string (Required) source database table and column name
storePath string (Required) the path of directory storing caches
keys string (Required) the primary keys of caching data, splited by comma, the number of keys must be identical with the number of filenames
filenames string (Required) the filename of caches, splited by comma, the number of filenames must be identical with the number of keys
fromDB: user_info.intro_json
storePath: ./cache/user-intro
keys: id001,id002,id003
filenames: about-us.json,contact-us.json,privacy-policy.json

Success Response: String in HTTP Header

Status: 200 OK
[
    "/var/www/cache/user-intro/about-us.json",
    "/var/www/cache/user-intro/contact-us.json",
    "/var/www/cache/user-intro/privacy-policy.json"
]

Error Response

Status: 400 Bad Request
{
    "status": "error",
    "message": "keys and filenames count not match"
}

2. File Transfer

2.1 Download File

GET /iapi/file

Remote server download file from server.

Request: String in HTTP Header, Parameter(s) in Query String

Header

Name Type Description
Authorization string (Required) Bearer type token,token content is API Key
Authorization: Bearer b01fd1c05d93e77a887fa6c8c91088bb7f053fb220eaf87d51e5efa30fea9d25

Query String

Name Type Description
filename string (Required) path and filename of downloading file
https://example.com/iapi/file?filename=public/images/1.jpg

Success Response: String in HTTP Header

Status: 200 OK
Content-Type: image/jpg

Error Response

Status: 400 Bad Request
{
    "status": "error",
    "message": "keys and filenames count not match"
}

2.2 Upload File

POST /iapi/file

Remote server upload file to server.

Request: String in HTTP Header, Parameter(s) in HTTP Body

Header

Name Type Description
Authorization string (Required) Bearer type token,token content is API Key
Authorization: Bearer b01fd1c05d93e77a887fa6c8c91088bb7f053fb220eaf87d51e5efa30fea9d25

Body

Name Type Description
content binary (Required) uploading file
filename string (Required) path and filename of uploading file
content: (binary)
filename: ./public/images/1.jpg

Success Response: String in HTTP Header

Status: 204 No Content

Error Response

Status: 400 Bad Request
{
    "status": "error",
    "message": "keys and filenames count not match"
}

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固