rename to gorush

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-04-13 15:22:04 +08:00
parent ceab65f733
commit 74e83d8726
20 changed files with 89 additions and 89 deletions

4
.gitignore vendored
View File

@ -29,6 +29,6 @@ config.yml
bin/*
.DS_Store
coverage.out
gopush/log/*.log
gorush/log/*.log
build.tar.gz
gopush.tar.gz
gorush.tar.gz

View File

@ -24,7 +24,7 @@ install:
- go get github.com/mattn/goveralls
script:
- cd gopush && go test -v -covermode=count -coverprofile=coverage.out
- cd gorush && go test -v -covermode=count -coverprofile=coverage.out
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out
-service=travis-ci -repotoken=$COVERALLS_TOKEN

View File

@ -3,9 +3,9 @@
VERSION=0.0.1
DEPS := $(wildcard *.go)
BUILD_IMAGE := "gopush-build"
TEST_IMAGE := "gopush-testing"
PRODUCTION_IMAGE := "gopush"
BUILD_IMAGE := "gorush-build"
TEST_IMAGE := "gorush-testing"
PRODUCTION_IMAGE := "gorush"
DEPLOY_ACCOUNT := "appleboy"
all: build
@ -14,17 +14,17 @@ build: clean
sh script/build.sh
test:
cd gopush && go test -v -covermode=count -coverprofile=coverage.out
cd gorush && go test -v -covermode=count -coverprofile=coverage.out
docker_build: clean
tar -zcvf build.tar.gz gopush.go gopush
tar -zcvf build.tar.gz gorush.go gorush
docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.build .
docker run --rm $(BUILD_IMAGE) > gopush.tar.gz
docker run --rm $(BUILD_IMAGE) > gorush.tar.gz
docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist .
docker_test:
@docker build --rm -t $(TEST_IMAGE) -f docker/Dockerfile.testing .
@docker run --rm -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TEST_IMAGE) sh -c "cd gopush && go test -v"
@docker run --rm -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TEST_IMAGE) sh -c "cd gorush && go test -v"
deploy:
ifeq ($(tag),)
@ -35,7 +35,7 @@ endif
docker push $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
lint:
golint gopush
golint gorush
clean:
-rm -rf build.tar.gz gopush.tar.gz bin/*
-rm -rf build.tar.gz gorush.tar.gz bin/*

View File

@ -1,8 +1,8 @@
# Gopush
# gorush
A push notification server using [Gin](https://github.com/gin-gonic/gin) framework written in Go (Golang).
[![GoDoc](https://godoc.org/github.com/appleboy/gopush?status.svg)](https://godoc.org/github.com/appleboy/gopush) [![Build Status](https://travis-ci.org/appleboy/gofight.svg?branch=master)](https://travis-ci.org/appleboy/gofight) [![Coverage Status](https://coveralls.io/repos/github/appleboy/gopush/badge.svg?branch=master)](https://coveralls.io/github/appleboy/gopush?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/gopush)](https://goreportcard.com/report/github.com/appleboy/gopush) [![codebeat badge](https://codebeat.co/badges/ee01d852-b5e8-465a-ad93-631d738818ff)](https://codebeat.co/projects/github-com-appleboy-gopush)
[![GoDoc](https://godoc.org/github.com/appleboy/gorush?status.svg)](https://godoc.org/github.com/appleboy/gorush) [![Build Status](https://travis-ci.org/appleboy/gofight.svg?branch=master)](https://travis-ci.org/appleboy/gofight) [![Coverage Status](https://coveralls.io/repos/github/appleboy/gorush/badge.svg?branch=master)](https://coveralls.io/github/appleboy/gorush?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/gorush)](https://goreportcard.com/report/github.com/appleboy/gorush) [![codebeat badge](https://codebeat.co/badges/ee01d852-b5e8-465a-ad93-631d738818ff)](https://codebeat.co/projects/github-com-appleboy-gorush)
## Support Platform
@ -54,18 +54,18 @@ log:
## Basic Usage
How to send push notification using `gopush` command? (Android or iOS)
How to send push notification using `gorush` command? (Android or iOS)
### Download a binary
The pre-compiled binaries can be downloaded from [release page](https://github.com/appleboy/gopush/releases).
The pre-compiled binaries can be downloaded from [release page](https://github.com/appleboy/gorush/releases).
### Send Android notification
Send single notification with the following command.
```bash
$ gopush -android -m="your message" -k="API Key" -t="Device token"
$ gorush -android -m="your message" -k="API Key" -t="Device token"
```
* `-m`: Notification message.
@ -77,7 +77,7 @@ $ gopush -android -m="your message" -k="API Key" -t="Device token"
Send single notification with the following command.
```bash
$ gopush -ios -m="your message" -i="API Key" -t="Device token"
$ gorush -ios -m="your message" -i="API Key" -t="Device token"
```
* `-m`: Notification message.
@ -87,15 +87,15 @@ $ gopush -ios -m="your message" -i="API Key" -t="Device token"
The default endpoint is APNs development. Please add `-production` flag for APNs production push endpoint.
```bash
$ gopush -ios -m="your message" -i="API Key" -t="Device token" -production
$ gorush -ios -m="your message" -i="API Key" -t="Device token" -production
```
## Run gopush web server
## Run gorush web server
Please make sure your [config.yml](config/config.yml) exist. Default port is `8088`.
```bash
$ gopush -c config.yml
$ gorush -c config.yml
```
Test status of api server using [httpie](https://github.com/jkbrzt/httpie) tool:
@ -106,7 +106,7 @@ $ http -v --verify=no --json GET https://localhost:8088/api/status
## Web API
Gopush support the following API.
gorush support the following API.
* **GET** `/api/status` Golang cpu, memory, gc, etc information. Thanks for [golang-stats-api-handler](https://github.com/fukata/golang-stats-api-handler).
* **POST** `/api/push` push ios and android notifications.
@ -341,16 +341,16 @@ Success response:
}
```
## Run gopush in Docker
## Run gorush in Docker
Set up `gopush` in the cloud in under 5 minutes with zero knowledge of Golang or Linux shell using our [gopush Docker image](https://hub.docker.com/r/appleboy/gopush/).
Set up `gorush` in the cloud in under 5 minutes with zero knowledge of Golang or Linux shell using our [gorush Docker image](https://hub.docker.com/r/appleboy/gorush/).
```bash
$ docker pull appleboy/gopush
$ docker run -name gopush -p 80:8088 appleboy/gopush
$ docker pull appleboy/gorush
$ docker run -name gorush -p 80:8088 appleboy/gorush
```
Testing your gopush server.
Testing your gorush server.
```bash
$ http -v --verify=no --json GET http://your.docker.host/api/status

10
doc.go
View File

@ -1,8 +1,8 @@
// A push notification server using Gin framework written in Go (Golang).
//
// Details about the gopush project are found in github page:
// Details about the gorush project are found in github page:
//
// https://github.com/appleboy/gopush
// https://github.com/appleboy/gorush
//
// Support Google Cloud Message using go-gcm library for Android.
// Support HTTP/2 Apple Push Notification Service using apns2 library.
@ -16,15 +16,15 @@
//
// Send Android notification
//
// $ gopush -android -m="your message" -k="API Key" -t="Device token"
// $ gorush -android -m="your message" -k="API Key" -t="Device token"
//
// Send iOS notification
//
// $ gopush -ios -m="your message" -i="API Key" -t="Device token"
// $ gorush -ios -m="your message" -i="API Key" -t="Device token"
//
// The default endpoint is APNs development. Please add -production flag for APNs production push endpoint.
//
// $ gopush -ios -m="your message" -i="API Key" -t="Device token" -production
// $ gorush -ios -m="your message" -i="API Key" -t="Device token" -production
//
// For more details, see the documentation and example.
//

View File

@ -7,6 +7,6 @@ RUN mkdir -p /tmp/build
Add build.tar.gz /tmp/build/
WORKDIR /tmp/build
RUN go get -v -d
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w" -o bin/gopush gopush.go
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w" -o bin/gorush gorush.go
CMD tar -C bin -czf - gopush
CMD tar -C bin -czf - gorush

View File

@ -7,8 +7,8 @@ RUN apk update && apk upgrade \
&& rm -rf /var/cache/apk/*
RUN mkdir /app
ADD gopush.tar.gz /app/
ADD gorush.tar.gz /app/
ADD config /app/config
WORKDIR /app
ENTRYPOINT ["./gopush", "-c", "config/config.yml"]
ENTRYPOINT ["./gorush", "-c", "config/config.yml"]
EXPOSE 8088

View File

@ -2,16 +2,16 @@ package main
import (
"flag"
"github.com/appleboy/gopush/gopush"
"github.com/appleboy/gorush/gorush"
"log"
)
func main() {
version := flag.Bool("v", false, "gopush version")
confPath := flag.String("c", "", "yaml configuration file path for gopush")
certificateKeyPath := flag.String("i", "", "iOS certificate key file path for gopush")
apiKey := flag.String("k", "", "Android api key configuration for gopush")
port := flag.String("p", "", "port number for gopush")
version := flag.Bool("v", false, "gorush version")
confPath := flag.String("c", "", "yaml configuration file path for gorush")
certificateKeyPath := flag.String("i", "", "iOS certificate key file path for gorush")
apiKey := flag.String("k", "", "Android api key configuration for gorush")
port := flag.String("p", "", "port number for gorush")
token := flag.String("t", "", "token string")
message := flag.String("m", "", "notification message")
android := flag.Bool("android", false, "send android notification")
@ -21,18 +21,18 @@ func main() {
flag.Parse()
if *version {
gopush.PrintGoPushVersion()
gorush.PrintGoRushVersion()
return
}
var err error
// set default parameters.
gopush.PushConf = gopush.BuildDefaultPushConf()
gorush.PushConf = gorush.BuildDefaultPushConf()
// load user define config.
if *confPath != "" {
gopush.PushConf, err = gopush.LoadConfYaml(*confPath)
gorush.PushConf, err = gorush.LoadConfYaml(*confPath)
if err != nil {
log.Printf("Load yaml config file error: '%v'", err)
@ -42,19 +42,19 @@ func main() {
}
if *certificateKeyPath != "" {
gopush.PushConf.Ios.PemKeyPath = *certificateKeyPath
gorush.PushConf.Ios.PemKeyPath = *certificateKeyPath
}
if *apiKey != "" {
gopush.PushConf.Android.APIKey = *apiKey
gorush.PushConf.Android.APIKey = *apiKey
}
// overwrite server port
if *port != "" {
gopush.PushConf.Core.Port = *port
gorush.PushConf.Core.Port = *port
}
if err = gopush.InitLog(); err != nil {
if err = gorush.InitLog(); err != nil {
log.Println(err)
return
@ -63,21 +63,21 @@ func main() {
// send android notification
if *android {
if len(*token) == 0 {
gopush.LogError.Fatal("Missing token flag (-t)")
gorush.LogError.Fatal("Missing token flag (-t)")
}
if len(*message) == 0 {
gopush.LogError.Fatal("Missing message flag (-m)")
gorush.LogError.Fatal("Missing message flag (-m)")
}
gopush.PushConf.Android.Enabled = true
req := gopush.PushNotification{
gorush.PushConf.Android.Enabled = true
req := gorush.PushNotification{
Tokens: []string{*token},
Platform: gopush.PlatFormAndroid,
Platform: gorush.PlatFormAndroid,
Message: *message,
}
gopush.PushToAndroid(req)
gorush.PushToAndroid(req)
return
}
@ -85,34 +85,34 @@ func main() {
// send android notification
if *ios {
if len(*token) == 0 {
gopush.LogError.Fatal("Missing token flag (-t)")
gorush.LogError.Fatal("Missing token flag (-t)")
}
if len(*message) == 0 {
gopush.LogError.Fatal("Missing message flag (-m)")
gorush.LogError.Fatal("Missing message flag (-m)")
}
if *production {
gopush.PushConf.Ios.Production = true
gorush.PushConf.Ios.Production = true
}
gopush.PushConf.Ios.Enabled = true
req := gopush.PushNotification{
gorush.PushConf.Ios.Enabled = true
req := gorush.PushNotification{
Tokens: []string{*token},
Platform: gopush.PlatFormIos,
Platform: gorush.PlatFormIos,
Message: *message,
}
gopush.InitAPNSClient()
gopush.PushToIOS(req)
gorush.InitAPNSClient()
gorush.PushToIOS(req)
return
}
if err = gopush.CheckPushConf(); err != nil {
gopush.LogError.Fatal(err)
if err = gorush.CheckPushConf(); err != nil {
gorush.LogError.Fatal(err)
}
gopush.InitAPNSClient()
gopush.RunHTTPServer()
gorush.InitAPNSClient()
gorush.RunHTTPServer()
}

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"gopkg.in/yaml.v2"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"github.com/stretchr/testify/assert"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
const (
// Version is gorush server version.

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"crypto/tls"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"github.com/Sirupsen/logrus"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"errors"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"fmt"

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"github.com/appleboy/gofight"
@ -19,8 +19,8 @@ func initTest() {
PushConf.Core.Mode = "test"
}
func TestPrintGoPushVersion(t *testing.T) {
PrintGoPushVersion()
func TestPrintGoRushVersion(t *testing.T) {
PrintGoRushVersion()
}
func TestRunNormalServer(t *testing.T) {
@ -85,7 +85,7 @@ func TestAPIStatusHandler(t *testing.T) {
Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
data := []byte(r.Body.String())
value, _ := jsonparser.GetString(data, "goVersion")
value, _ := jsonparser.GetString(data, "go_version")
assert.Equal(t, goVersion, value)
assert.Equal(t, http.StatusOK, r.Code)

View File

@ -1,4 +1,4 @@
package gopush
package gorush
import (
"fmt"
@ -6,9 +6,9 @@ import (
"runtime"
)
// PrintGoPushVersion provide print server engine
func PrintGoPushVersion() {
fmt.Printf(`GoPush %s, Compiler: %s %s, Copyright (C) 2016 Bo-Yi Wu, Inc.`,
// PrintGoRushVersion provide print server engine
func PrintGoRushVersion() {
fmt.Printf(`GoRush %s, Compiler: %s %s, Copyright (C) 2016 Bo-Yi Wu, Inc.`,
Version,
runtime.Compiler,
runtime.Version())
@ -18,7 +18,7 @@ func PrintGoPushVersion() {
func VersionMiddleware() gin.HandlerFunc {
// Set out header value for each response
return func(c *gin.Context) {
c.Writer.Header().Set("Server-Version", "GoPush/"+Version)
c.Writer.Header().Set("Server-Version", "GoRush/"+Version)
c.Next()
}
}

View File

@ -5,11 +5,11 @@ ARCH="amd64"
for GOOS in $OS; do
for GOARCH in $ARCH; do
EXE="gopush"
(test "$GOOS" = "windows") && EXE="gopush.exe"
EXE="gorush"
(test "$GOOS" = "windows") && EXE="gorush.exe"
echo "Build: ${GOOS}, Arch: ${GOARCH}, EXE: ${EXE}"
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-w" -o bin/$GOOS/$GOARCH/${EXE} gopush.go;
tar -C bin/$GOOS/$GOARCH -czf bin/gopush-$GOOS-$GOARCH.tar.gz gopush
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-w" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
tar -C bin/$GOOS/$GOARCH -czf bin/gorush-$GOOS-$GOARCH.tar.gz gorush
done
done