在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:dhax/go-base开源软件地址:https://github.com/dhax/go-base开源编程语言:Go 97.5%开源软件介绍:Go Restful API BoilerplateEasily extendible RESTful API boilerplate aiming to follow idiomatic go and best practice. The goal of this boiler is to have a solid and structured foundation to build upon on. Any feedback and pull requests are welcome and highly appreciated. Feel free to open issues just for comments and discussions. FeaturesThe following feature set is a minimal selection of typical Web API requirements:
Start Application
Or just use the provided docker-compose file. After first start attach to the server container and run API RoutesAuthenticationFor passwordless login following routes are available:
Example APIBesides /auth/_ the API provides two main routes /api/_ and /admin/*, as an example to separate application and administration context. The latter requires to be logged in as administrator by providing the respective JWT in Authorization Header. Check routes.md for a generated overview of the provided API routes. Client API Access and CORSThe server is configured to serve a Progressive Web App (PWA) client from ./public folder (this repo only serves an example index.html, see below for a demo PWA client to put here). In this case enabling CORS is not required, because the client is served from the same host as the api. If you want to access the api from a client that is serverd from a different host, including e.g. a development live reloading server with below demo client, you must enable CORS on the server first by setting environment variable ENABLE_CORS=true on the server to allow api connections from clients serverd by other hosts. Demo client applicationFor demonstration of the login and account management features this API serves a demo Vue.js PWA. The client's source code can be found here. Build and put it into the api's ./public folder, or use the live development server (requires CORS enabled). Outgoing emails containing the login token will be print to stdout if no valid email smtp settings are provided by environment variables (see table below). If EMAIL_SMTP_HOST is set but the host can not be reached the application will exit immediately at start. Use one of the following bootstrapped users for login:
A deployed version can also be found on Heroku Environment VariablesBy default viper will look at $HOME/.go-base.yaml for a config file. Setting your config as Environment Variables is recommended as by 12-Factor App.
TestingPackage auth/pwdless contains example api tests using a mocked database. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论