Coder Social home page Coder Social logo

fin's Introduction

fin

gin风格的微型web api框架,内置gorm

本框架仅供学习参考,不建议用于生产环境

想学gin+gorm?传送门:https://github.com/feizhiwu/go-stage

运行demo

> git clone ...
> cd fin
> go run example/main.go

RESTful API curl

添加用户:
curl --location --request POST 'http://localhost:8080/v1/user' \
--header 'action: add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name":"tout",
    "password":"123"
}'

用户列表:
curl --location --request GET 'http://localhost:8080/v1/user?page=1&limit=10' \
--header 'action: list'

用户详情:
curl --location --request GET 'http://localhost:8080/v1/user?id=1' \
--header 'action: info'

修改用户:
curl --location --request PUT 'http://localhost:8080/v1/user' \
--header 'action: update' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id":1,
    "password":"123456"
}'

删除用户:
curl --location --request DELETE 'http://localhost:8080/v1/user' \
--header 'action: delete' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id":1
}'

注:一个router下的header action需与controller方法同名,联调时可以通过action快速定位接口

返参示例

{
    "status": 10000,
    "msg": "请求成功",
    "body": null
}

测试user表结构

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

fin's People

Contributors

feizhiwu avatar

Stargazers

 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.