Giter Site home page Giter Site logo

caoxiaoxin / json-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stleary/json-java

0.0 0.0 0.0 751 KB

A reference implementation of a JSON package in Java.

Home Page: http://stleary.github.io/JSON-java/index.html

License: Other

Java 100.00%

json-java's Introduction

wxcloudrun-golang

GitHub license GitHub package.json dependency version (prod)

微信云托管 golang 模版,实现简单的计数器读写接口,使用云托管 MySQL 读写、记录计数值。

快速开始

前往 微信云托管快速开始页面,选择相应语言的模板,根据引导完成部署。

本地调试

下载代码在本地调试,请参考微信云托管本地调试指南

实时开发

代码变动时,不需要重新构建和启动容器,即可查看变动后的效果。请参考微信云托管实时开发指南

Dockerfile最佳实践

请参考如何提高项目构建效率

目录结构说明

.
├── Dockerfile                Dockerfile 文件
├── LICENSE                   LICENSE 文件
├── README.md                 README 文件
├── container.config.json     模板部署「服务设置」初始化配置(二开请忽略)
├── db                        数据库逻辑目录
├── go.mod                    go.mod 文件
├── go.sum                    go.sum 文件
├── index.html                主页 html 
├── main.go                   主函数入口
└── service                   接口服务逻辑目录

服务 API 文档

GET /api/count

获取当前计数

请求参数

响应结果

  • code:错误码
  • data:当前计数值
响应结果示例
{
  "code": 0,
  "data": 42
}

调用示例

curl https://<云托管服务域名>/api/count

POST /api/count

更新计数,自增或者清零

请求参数

  • actionstring 类型,枚举值
    • 等于 "inc" 时,表示计数加一
    • 等于 "clear" 时,表示计数重置(清零)
请求参数示例
{
  "action": "inc"
}

响应结果

  • code:错误码
  • data:当前计数值
响应结果示例
{
  "code": 0,
  "data": 42
}

调用示例

curl -X POST -H 'content-type: application/json' -d '{"action": "inc"}' https://<云托管服务域名>/api/count

使用注意

如果不是通过微信云托管控制台部署模板代码,而是自行复制/下载模板代码后,手动新建一个服务并部署,需要在「服务设置」中补全以下环境变量,才可正常使用,否则会引发无法连接数据库,进而导致部署失败。

  • MYSQL_ADDRESS
  • MYSQL_PASSWORD
  • MYSQL_USERNAME 以上三个变量的值请按实际情况填写。如果使用云托管内MySQL,可以在控制台MySQL页面获取相关信息。

License

MIT

json-java's People

Contributors

ajayk avatar andrew-fletcher avatar bpieber avatar brianrussell2 avatar douglascrockford avatar dtalex avatar erosb avatar fleipold avatar foldvari avatar guywithnose avatar joeferner avatar johnjaylward avatar madsager avatar migueltt avatar netheril96 avatar omarzina avatar philippgille avatar run2000 avatar skreutzer avatar stleary avatar ttulka avatar xxxertetet avatar yaccob avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.