dep ensure
and go build -o ~/bin/tokyo-c-server
to build into ~/bin/tokyo-c-server
.
cat > start-server
below and chmod +x start-server
.
#!/bin/bash
export TOKYO_C_DATABASE_HOST=" "
export TOKYO_C_DATABASE_USER=" "
export TOKYO_C_DATABASE_PASSWORD=" "
export TOKYO_C_DATABASE_NAME="tokyoC_`date +%Y%m%d%H%M%S`"
export TOKYO_C_DATABASE_URI="${TOKYO_C_DATABASE_USER}:${TOKYO_C_DATABASE_PASSWORD}@tcp(${TOKYO_C_DATABASE_HOST})/${TOKYO_C_DATABASE_NAME}"
./install-database
DATABASE_TYPE=mysql DATABASE_URI="${TOKYO_C_DATABASE_URI}" go run *.go -port 9000 &
PID="$!"
mysql --user="${TOKYO_C_DATABASE_USER}" --host="${TOKYO_C_DATABASE_HOST}" --password="${TOKYO_C_DATABASE_PASSWORD}" "${TOKYO_C_DATABASE_NAME}"
kill -KILL "${PID}"
mysql --user="${TOKYO_C_DATABASE_USER}" --host="${TOKYO_C_DATABASE_HOST}" --password="${TOKYO_C_DATABASE_PASSWORD}" <<EOS
DROP DATABASE ${TOKYO_C_DATABASE_NAME};
EOS
cat > firebase-credentials.json
Execute ./start-server
- GET /messages gives a realtime stream of messages of channel.
- Parameters
channel
specifies a channel which you want to listen.since_id
(optional) specifies a message id from which digging message archive starts.
- Response (application/json stream): []Message (data_types.go)
- Parameters
- POST /messages takes a message and broadcast it.
- Payload (application/json): Message (data_types.go)
- GET /messages/id gives a message of id.
- Response (application/json): Message (data_types.go)
- GET /friendships gives a friend list of the current user.
- Repsponse (application/json): []string
- POST /friendships takes PIN and sends a request to the owner.
- Payload (application/json): PIN code
- PUT /friendships/person makes a friendship from the current user to person (requiring that person send a request with PIN).
- Repsponse (application/json): []string
- DELETE /friendships/person dissolves a friendship from the current user to person.
- Repsponse (application/json): []string
- GET /channels gives a channel list the current user is participating in.
- Response (application/json): Channel (data_type.go)
- POST /channels makes a new channel with the only participant being the current user.
- Payload (application/json): Channel (data_type.go)
- GET /channels/channel gives details of channel
- Response (application/json): Channel (data_type.go)
- POST /channels/channel/person performs a bulk invitation.
- Payload (application/json): []string
- Response (application/json): Channel (data_type.go)
- PUT /channels/channel/person makes person participate in channel (requiring that the current user be a member).
- Response (application/json): Channel (data_type.go)
- DELETE /channels/channel/person makes person withdraw from channel. (requiring that the current user be a member. the channel will perish if the current user is the last participant).
- Response (application/json): Channel (data_type.go)
- PATCH /channels/channel takes a differential data and modifies the information of channel.
- Payload (application/x-www-form-urlencoded): name (optoinal)
- GET /pin gives a realtime stream of event messages
- Response (application/json stream): PINEvent (data_types.go) (Type is
pin
->request
ornoop
)
- Response (application/json stream): PINEvent (data_types.go) (Type is
- GET /people/person gives a firebase user info of person
- Response (application/json): Refer to auth.UserInfo (firebase)
- GET /status gives the current status of the current user
- Response (application/json): Status (data_types.go)