Skip to content

Commit

Permalink
handler: Move to outer level package
Browse files Browse the repository at this point in the history
  • Loading branch information
nkprince007 committed May 25, 2018
1 parent 37a1cf3 commit 0e0c594
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion handler/handler.go → handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package handler
package main

import (
"crypto/hmac"
Expand Down
14 changes: 6 additions & 8 deletions handler/handler_test.go → handler_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package handler_test
package main

import (
"bytes"
Expand All @@ -10,8 +10,6 @@ import (
"os"
"syscall"
"testing"

"gitlab.com/nkprince007/listen/handler"
)

func generateGhSign(secret string, body []byte) string {
Expand All @@ -21,7 +19,7 @@ func generateGhSign(secret string, body []byte) string {
}

func TestCaptureWrongMethod(t *testing.T) {
var ts = httptest.NewServer(http.HandlerFunc(handler.Capture))
var ts = httptest.NewServer(http.HandlerFunc(Capture))
defer ts.Close()

res, err := http.Get(ts.URL)
Expand All @@ -36,7 +34,7 @@ func TestCaptureWrongMethod(t *testing.T) {
}

func TestNoMatchingProvider(t *testing.T) {
var ts = httptest.NewServer(http.HandlerFunc(handler.Capture))
var ts = httptest.NewServer(http.HandlerFunc(Capture))
defer ts.Close()

// no explicit X-*-Event header has been set on request
Expand Down Expand Up @@ -65,7 +63,7 @@ func TestGitHubSignatureVerification(t *testing.T) {
reqBody := []byte("{}")
sign := generateGhSign("secret", reqBody)

var ts = httptest.NewServer(http.HandlerFunc(handler.Capture))
var ts = httptest.NewServer(http.HandlerFunc(Capture))
defer ts.Close()

data := bytes.NewBuffer(reqBody)
Expand Down Expand Up @@ -118,7 +116,7 @@ func TestGitLabSignatureVerification(t *testing.T) {
}()

reqBody := []byte("{}")
var ts = httptest.NewServer(http.HandlerFunc(handler.Capture))
var ts = httptest.NewServer(http.HandlerFunc(Capture))
defer ts.Close()

data := bytes.NewBuffer(reqBody)
Expand Down Expand Up @@ -175,7 +173,7 @@ func TestNoSignatureVerification(t *testing.T) {
}
}()

var ts = httptest.NewServer(http.HandlerFunc(handler.Capture))
var ts = httptest.NewServer(http.HandlerFunc(Capture))
defer ts.Close()

data := bytes.NewBuffer([]byte("{}"))
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/micro/go-log"
"github.com/micro/go-web"
"gitlab.com/nkprince007/listen/handler"
)

func main() {
Expand All @@ -25,7 +24,7 @@ func main() {
)

// register call handler
service.HandleFunc("/", handler.Capture)
service.HandleFunc("/", Capture)

// initialise service
if err := service.Init(); err != nil {
Expand Down

0 comments on commit 0e0c594

Please sign in to comment.