Skip to content

Commit

Permalink
Add initial set of files
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranza committed Sep 18, 2018
1 parent 25d923e commit 746dbef
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
image: golang:1.10
stages:
- build

before_script:
- go get -u github.com/golang/dep/cmd/dep
- mkdir -p /go/src/gitlab.com/yakshaving.art
- cp -r /builds/yakshaving.art/propaganda /go/src/gitlab.com/yakshaving.art/
- cd /go/src/gitlab.com/yakshaving.art/propaganda
- dep ensure

build:
stage: build
script:
- go build

# test:
# stage: test
# coverage: '/^total:\s+\(statements\)\s+(\d+.\d+)%$/'
# script:
# - go test -v -coverprofile=coverage.out $(go list ./... | grep -v '/vendor/') && go tool cover -func=coverage.out
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[prune]
go-tests = true
unused-packages = true
44 changes: 44 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"fmt"
"net/http"

"github.com/onrik/logrus/filename"
"github.com/sirupsen/logrus"
)

func main() {
setupLogger()

http.HandleFunc("/github", handleGithub)

logrus.Fatal(http.ListenAndServe(":9999", nil))
}

func handleGithub(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
logrus.Debugf("Failed to parse form on request %s: %#v", r, err)
http.Error(w, fmt.Sprintf("bad request: %s", err), http.StatusBadRequest)
return
}

payload := r.FormValue("payload")
if payload == "" {
logrus.Debugf("No payload in form %#v", r.Form)
http.Error(w, "no payload in form", http.StatusBadRequest)
return
}

w.WriteHeader(http.StatusAccepted)

logrus.Println("Received Webhook payload: %s", payload)
}

func setupLogger() {
logrus.AddHook(filename.NewHook())
logrus.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
logrus.SetLevel(logrus.DebugLevel)
}

0 comments on commit 746dbef

Please sign in to comment.