Giter Site home page Giter Site logo

go_web_server's Introduction

Run Unit Testing

Steps

<!-- Run unit testing and create coverage file -->
go test ./... -coverprofile cover.out

<!-- Check coverage file -->
go tool cover -func cover.out   

API Doc

Gmail Sender

Send ( POST: /gmail/send )

  • Authorization
Basic Base64Encode(login_token: string)
  • Body
  {
    recipient: string,
    msg: string
  }

User

Create ( POST: /user/create )

  • Authorization
Bearer Base64Encode(creating_user_auth_token: string)
  • Body
  {
    user_account: string,
    user_password: string,
    first_name: string (optional),
    last_name: string (optional),
    gender: uint8 (optional) // (Default: 0, Male: 1, Female: 2, Diver: 3),
    height_cm_val: float32 (optional),
    birthday: string (optional) // yyyy-mm-dd (Default: 1000-01-01),
    email: string,
    phone: string (optional),
    user_profile: string (optional),
    role: uint8
  }
  • Response
- 400 Invalid request body
- 400 Missing required fields
- 401 Authorization format is incorrect
- 401 Token is incorrect!
- 500 Failed to get user service
- 201

Update ( PUT: /user/update?user_id={ uint64 } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Body
  {
    first_name: string (optional),
    last_name: string (optional),
    gender: uint8 (optional),
    height_cm_val: float32 (optional),
    height_unit: uint8 (optional) // (default: 0, cm: 0, ft: 1),
    weight_unit: uint8 (optional) // (default: 0, kg: 0, lb: 1),
    birthday: string (optional) // yyyy-mm-dd,
    email: string (optional),
    country_code: string (optional),
    phone: string (optional),
    allergies: string (optional),
    drug_intolerance: string (optional),
    mobility: uint8 (optional) //default 0,
  }
  • Response
- 400 Invalid user_id
- 400 Invalid request body
- 500 Failed to get user service
- 204

Upload Profile ( POST: /user/upload_user_profile?user_id={ uint64 } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Body
  {
    file: multipart.File
  }
  • Response
- 400 Invalid user_id
- 400 Error Retrieving the File
- 500 Failed to get user service
- 200

Get ( GET: /user/get?user_id={ uint64 } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Response
- 400 Invalid user_id
- 500 Failed to get user service
- 200
  {
    user_id: uint64,
    user_account: string,
    first_name: string,
    last_name: string,
    gender: uint8,
    height_cm_val: float32,
    height_unit: uint8,
    weight_unit: uint8, 
    birthday: string // yyyy-mm-dd,
    email: string,
    phone: string,
    user_profile: string
  }

Get By Account ( GET: /user/get_by_account?user_account={ string } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Response
- 400 Invalid user_account
- 500 Failed to get user service
- 200
  {
    user_id: uint64,
    user_account: string,
    first_name: string,
    last_name: string,
    gender: uint8,
    user_profile: string
  }

Get All ( GET: /user/get_all )

  • Authorization
Basic Base64Encode(login_token: string)
  • Response
- 500 Failed to get user service
- 200
[
  {
    user_id: uint64,
    user_account: string,
    first_name: string,
    last_name: string,
    gender: uint8,
    height_cm_val: float32 (optional),
    birthday: string // yyyy-mm-dd,
    email: string,
    phone: string,
    user_profile: string
  }, ...
]

Get Specific Roles ( GET: /user/get_specific_roles?role={ uint8 } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Response
- 400 Invalid role
- 500 Failed to get user service
- 200
[
  {
    user_id: uint64,
    user_account: string,
    first_name: string,
    last_name: string,
    gender: uint8,
    birthday: string // yyyy-mm-dd,
    email: string,
    phone: string,
    user_profile: string
  }, ...
]

Delete ( DELETE: /user/delete?user_id={ uint64 } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Response
- 400 Invalid user_id
- 500 Failed to get user service
- 204

Login ( POST: /user/login )

  • Authorization
Basic Base64Encode(( user_account: string ):( Base64Encode(user_password: string) ))
  • Body
{
  role: uint8 // Patient = 1, Caregiver = 2, Admin = 99 
}
  • Response
- 500 Failed to get user service
- 200
{
  login_token: string,
  user_id: uint64
}

Get Login Token ( GET: /user/get_login_token?user_id={ uint64 } )

  • Authorization
Basic Base64Encode(login_token: string)
  • Response
- 400 Invalid user_id
- 500 Failed to get user service
- 200 string

go_web_server's People

Contributors

shingshen 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.