{"id":15178966,"url":"https://github.com/rogary/mysql-restful-server","last_synced_at":"2025-10-26T18:31:42.180Z","repository":{"id":48047891,"uuid":"116348587","full_name":"Rogary/mysql-restful-server","owner":"Rogary","description":"get restful data from mysql with simple config，with out coding","archived":false,"fork":false,"pushed_at":"2023-05-05T02:28:36.000Z","size":64,"stargazers_count":4,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-28T15:42:46.270Z","etag":null,"topics":["go","golang","jwt","mysql","mysql-database","mysql-resful","rest-api","restful","restful-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rogary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-05T06:05:29.000Z","updated_at":"2021-08-10T01:11:25.000Z","dependencies_parsed_at":"2024-06-19T05:28:40.858Z","dependency_job_id":"d4feddb8-d54e-4fce-aaa8-2c969a7281fb","html_url":"https://github.com/Rogary/mysql-restful-server","commit_stats":{"total_commits":29,"total_committers":3,"mean_commits":9.666666666666666,"dds":0.1724137931034483,"last_synced_commit":"33d04ffff5e1485dd695152337a3c34413e79107"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rogary%2Fmysql-restful-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rogary%2Fmysql-restful-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rogary%2Fmysql-restful-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rogary%2Fmysql-restful-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rogary","download_url":"https://codeload.github.com/Rogary/mysql-restful-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862312,"owners_count":16555956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","jwt","mysql","mysql-database","mysql-resful","rest-api","restful","restful-api"],"created_at":"2024-09-27T15:42:46.296Z","updated_at":"2025-10-26T18:31:41.765Z","avatar_url":"https://github.com/Rogary.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-mysql-rest-api\n\nA guide for creating RESTful API with Golang and MySQL and Gin.\n\n## Build and Usage\n\n```bash\ngo mod tidy\ngo mod verify\ngo build\n```\n\n```bash\n./mysql-restful-server\n```\n\n```bash\nhttp://localhost:8989\n```\n\n\nbuild with docker\n```\ndocker run --rm -v \"$PWD\":/usr/src/myapp -w /usr/src/myapp golang:1.15 go build -v\n```\n\nbuild docker image\n```\ndocker build -t go-mysql-restful-server .\n```\n \nrun in docker with confYaml \n```\ndocker run -it -v .conf.yaml:/go/src/app/conf.yaml --rm --name my-running-app go-mysql-restful-server\n```\nrun in docker with Environment \n\n```\ndocker run -it -e MYSQL_HOST=\"\" ................  --rm --name my-running-app go-mysql-restful-server\n```\n\ndocker  Environment\n```\n# MYSQL_HOST\n# MYSQL_PORT\n# MYSQL_USER\n# MYSQL_PWD\n# MYSQL_DB\n# MYSQL_ENABLE_AUTH\n# MYSQL_AUTH_TABLE\n# MYSQL_AUTH_NAME_FIEL\n# MYSQL_AUTH_PWD_FIELD\n```\n\n\n## Config\n\nconf.yaml\nyou can conf from env \n\nEnvironment takes precedence over configuration files\n```yaml\nmysql:\n  host: \"127.0.0.1\"                # MYSQL_HOST\n  port: \"3306\"                     # MYSQL_PORT\n  user: \"root\"                     # MYSQL_USER\n  pwd: \"root\"                      # MYSQL_PWD\n  db: \"test\"                       # MYSQL_DB\n  enable_auth: \"true\"              # MYSQL_ENABLE_AUTH\n  auth_table: \"auth\"               # MYSQL_AUTH_TABLE\n  auth_name_field: \"username\"      # MYSQL_AUTH_NAME_FIELD\n  auth_pwd_field: \"passwd\"         # MYSQL_AUTH_PWD_FIELD\n```\nfor security all insert / delete / update operation must login  \nso if you want to insert / delete / update data please enable auth  \n\nyou have no permission to read or modify any data from ```auth_table```  \n\nTODO： Need to guard against the risk of SQL injection attacks\n\n## Features\n\n* Generates API for MySql database\n* can not use ${auth_table}\n\n## API\n\n|Method         | Path           | Auth  | Operation  |\n| :-------------: |:-------------| :-----:| :-----:| \n| GET     | /api/v1/:tableName/:id | NO | serect * from tableName where id = ? |\n| GET     | /api/v1/:tableName?order=desc\u0026page=0\u0026size=20 | NO | select * from tableName where id\u003e0 order by id desc limit 0,20 |\n| POST     | /login | NO | login |\n| GET     | /api/refresh_token | YES | refresh_token |\n| DELETE     | /api/v1/:tableName/:id | YES | delete from tableName where id = ? |\n| POST     | /api/v1/:tableName| YES | insert into tableName (data.key) values (data.value) |\n| PUT     | /api/v1/:tableName/:id | YES | update from tableName  where id = ? | \n\n\n## Security\n\n### Login API:\n\n```bash\nPOST /login HTTP/1.1\nHost: 127.0.0.1:8989\nContent-Type: application/json\nCache-Control: no-cache\n{\n\t\"username\":\"admin\",\n\t\"password\":\"admin\"\n}\n\n{\n    \"code\": 200,\n    \"expire\": \"2018-01-05T15:26:18+08:00\",\n    \"token\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTUxMzcxNzgsImlkIjoiYWRtaW4iLCJvcmlnX2lhdCI6MTUxNTEzMzU3OH0.D48Ada0pVR72nAS_gt8TTxzvtdy2s-OAnoizbmRIhtunciw5905G7QCcJZHqJvxcje4GBWA6e9wvOOEz7OVk9lrsTxPfFHwSnqkoj7ZkCGGkOIYkC-SVaVJB47Ez6yxhQljwHf_LiWVnkLpBN4y4eerqEErh-R4VXmZ9ZnJQdO3V78ZiXdaY2oMAmX7-JYHz6LOlTqjxMsZ8KHUrRRt5mDbLZxw4Ni_Ww-vetR3dNwIsCH_-ExsE6Z9UQlOP_yTo7iD09_sbyeSAB-ZE0e7qnOjgWCgujZJxFPsoWCIQV4O4ONWTpVZxds3eLjWIlyBlyV2LHi85b2f-nmOfRQphDw\"\n}\n\n```\n\n\n### Refresh token API:\n\n```bash\nGET /api/refresh_token HTTP/1.1\nHost: 127.0.0.1:8989\nAuthorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTUxMzcxNzgsImlkIjoiYWRtaW4iLCJvcmlnX2lhdCI6MTUxNTEzMzU3OH0.D48Ada0pVR72nAS_gt8TTxzvtdy2s-OAnoizbmRIhtunciw5905G7QCcJZHqJvxcje4GBWA6e9wvOOEz7OVk9lrsTxPfFHwSnqkoj7ZkCGGkOIYkC-SVaVJB47Ez6yxhQljwHf_LiWVnkLpBN4y4eerqEErh-R4VXmZ9ZnJQdO3V78ZiXdaY2oMAmX7-JYHz6LOlTqjxMsZ8KHUrRRt5mDbLZxw4Ni_Ww-vetR3dNwIsCH_-ExsE6Z9UQlOP_yTo7iD09_sbyeSAB-ZE0e7qnOjgWCgujZJxFPsoWCIQV4O4ONWTpVZxds3eLjWIlyBlyV2LHi85b2f-nmOfRQphDw\nCache-Control: no-cache\n\n{\n    \"code\": 200,\n    \"expire\": \"2018-01-05T15:26:55+08:00\",\n    \"token\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTUxMzcyMTUsImlkIjoiYWRtaW4iLCJvcmlnX2lhdCI6MTUxNTEzMzU3OH0.lWJC6BaK5XC9N1Wc66MnxDJD-JXOCdAFwW7qGeIjRvPn6R5vYWgB559zeOC8bLxqhZW7CFZplzZQwuM9H3AjQuU5u7Iiaw4zjS1c2W180U_dPqUz1IeZA3zLpuSLjvNWAxGS-iw7B7aUmpJ7KC9ubBHLItXenKbiZn77SOys3zgNwLm_BfkoOMZj2GXxZPLderxj7GR06oNeARy_hXTUM4wa4-C83R6x5OH22VJXiXmNhIDBv5m0AiK7JYZmpbMr6gSGTNVhUM5971ww7u64Ly2viSO0_vnPWR-L-zOKZVVjwJAkdzScpxXnHyXOQTSKcrJETh7OBL4lU2TaQm941w\"\n}\n```\n\n## TODO\n\n- ~~security API~~\n- ~~DELETE API~~\n- ~~POST API~~\n- PUT API\n- create table API\n- alert API\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogary%2Fmysql-restful-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogary%2Fmysql-restful-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogary%2Fmysql-restful-server/lists"}