RJHsiao / api-exercise-go

A side project to build a simple login API for learning Golang.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Exercise - Go

A simple, prototyping account management API service developing with Golang, that can:

  1. Register a new account.
  2. Login/logout.
  3. Show/edit account info.

Runtime Environment

  • Go v1.11 with Go Module
  • MongoDB v3.6+

3rd Library/Toolkit

How To Launch

  1. Clone this project to local.
  2. Shift to the project folder.
  3. Generate swagger doc files: swag init -g routes/routes.go
    P.S. You need to run this command to re-generate swagger doc files everytime you modified Go annotations for changing API spec.
  4. Run go build main.go to build project on the first time.
  5. Launch service: run ./main on Linux/macOS, or .\main.exe on Windows.

Options: config.json

  • host: the host name (IP, domain name) listening. Default: localhost
  • port: the number of HTTP port for listening. Default: 3000
  • database: the connection URL to connect the MongoDB for data storage. Default: mongodb://localhost/api-exercise

Testing, Documentation

Documentation & Testing UI generated by swagger. URL: http://<hostname_or_ip>:<port>/swagger/
Default URL: http://localhost:3000/swagger/

Attention

  • Do user register first before login.
  • Show/Edit user info API will work fine when session key exist into header. Session key will generated by login API.

About

A side project to build a simple login API for learning Golang.


Languages

Language:Go 100.0%