hive

command module
v0.0.0-...-f3497b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2019 License: MIT Imports: 4 Imported by: 0

README

hive logo

hive

Build Status Go Report Card codebeat badge License

Hive is the light-weight and elegant message center for developers

Origin

Originally LAM, hive is now a more elegant way to collect your messages.

Use

Hive is under heavy develop and has no official release version at the present. If you would like to try it now, try Develop option shown below.

Pushers

Develop

Prepare

Hive use go mod for dependency management. Run go build in project folder will install all dependencies under $GOPATH/pkg/mod/ folder.

Database

To use hive, you need a database named hive, and tables as follows:

  • message

    • id(INT) [PRIMARY, AUTO_INCREMENT]
    • tag(VARCHAR)
    • admin(VARCHAR)
    • content(TEXT)
    • timestamp(DATETIME)
  • token

    • tag(VARCHAR) [PRIMARY]
    • token(VARCHAR)
    • admin(VARCHAR)
    • timestamp(DATETIME)
  • admin

    • name(VARCHAR) [PRIMARY]
    • token(VARCHAR)
    • timestamp(DATETIME)

There's an sql file under sql/ for you to import

Build and test

Navigate to project folder, simply run

go build main.go

Rename the built file to hive, then you shall run server with command

hive start 0.0.0.0:12580

You shall see a welcome page by visiting http://0.0.0.0:12580/hello. More commands can be found with command hive help

Pages

/hello

Welcome and navigation page of hive

/auth

Enter your admin token to grant you permission for using /dashboard and /panel, session is valid for 24 hours

/panel

Show server status, informations about this hive and so on

/dashboard

Show tags of the authorized admin, as well as messages. Dashboard automatically refresh message list every 5 seconds

APIs

/auth
  • Method: POST
  • Require:
{
  "token": "Your token here"
}
  • Respond:
{
  "code": 200,
  "text": "Token verified",
  "method": "POST"
}
/info
  • Method: POST
  • Require:
{
  "sessionId": "Your session ID here"
}
  • Respond:
{
  "code": 200,
  "text": "Session verified",
  "adminName": "Your admin name",
  "startTime": "2018-08-08 18:08:08",
  "serverOS": "linux",
  "serverArch": "amd64",
  "method": "POST"
}
/session
  • Method: POST
  • Require:
{
  "sessionId": "Your session ID here"
}
  • Respond:
{
  "code": 200,
  "text": "Session verified",
  "method": "POST"
}
/messages
  • Method: POST
  • Require:
{
  "sessionId": "Your session ID here"
}
  • Respond:
{
  "code": 200,
  "text": "Session verified",
  "messages": [
    {"id": 0, "tag": "wow", "admin": "test", "content": "hello", "timestamp": "2018-08-09T16:22:59Z"}
  ],
  "method": "POST"
}
/send
  • Method: POST
  • Require:
{
  "text": "Your message here",
  "token": "Your token here"
}
  • Respond:
{
  "code": 200,
  "text": "Message from Your tag saved",
  "method": "POST"
}

To-dos

  • Code pushers and command-line pusher
  • Add super admin and a button to restart hive for him/her
  • Add limit for API request(e.g. 60/min)
  • Improve token generate methods
  • Running with goroutine
  • Server daemon

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL