Skip to content

Commit

Permalink
adding root handler
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyhulen committed Dec 1, 2015
1 parent fbe36b0 commit 6c9f470
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ clean:

run: .prepare
@echo Starting go web server
$(GO) run $(GOFLAGS) main.go -config=config.json &
$(GO) run $(GOFLAGS) main.go
31 changes: 31 additions & 0 deletions build/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# copy following lines to /etc/init/matter-push-proxy.conf

# start on runlevel [2345]
# stop on runlevel [016]
# respawn
# chdir /home/ubuntu/matter-push-proxy
# setuid ubuntu
# console output
# exec bin/push-proxy | logger

sudo stop matter-push-proxy


rm -f matter-push-proxy.tar.gz
rm -rf ~/matter-push-proxy

wget https://github.com/mattermost/push-proxy/releases/download/v0.1.0/matter-push-proxy.tar.gz

mkdir -p ~/matter-push-proxy

tar -C ~/ -xzf matter-push-proxy.tar.gz

cp config.json ~/matter-push-proxy/config/config.json

sudo start matter-push-proxy

sleep 10

curl localhost:8066
6 changes: 6 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func Start() {

handler = th.Throttle(router)

router.HandleFunc("/", root).Methods("GET")

r := router.PathPrefix("/api/v1").Subrouter()
r.HandleFunc("/send_push", handleSendNotification).Methods("POST")

Expand All @@ -57,6 +59,10 @@ func Stop() {
manners.Close()
}

func root(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("<html><body>Mattermost Push Proxy</body></html>"))
}

func handleSendNotification(w http.ResponseWriter, r *http.Request) {
msg := PushNotificationFromJson(r.Body)

Expand Down

0 comments on commit 6c9f470

Please sign in to comment.