mirror of
https://github.com/alvierahman90/gohookr.git
synced 2024-11-24 12:59:53 +00:00
Make enpoint prefix plural, change stuff in readme
This commit is contained in:
parent
b4d9935e39
commit
76197520e7
8
main.go
8
main.go
@ -16,12 +16,12 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
var config_filename = "/etc/ghookr.json"
|
var config_filename = "/etc/gohookr.json"
|
||||||
var noSignatureCheck = false
|
var noSignatureCheck = false
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
r.HandleFunc("/webhook/{service}", webhook)
|
r.HandleFunc("/webhooks/{service}", webhookHandler)
|
||||||
|
|
||||||
port := ":80"
|
port := ":80"
|
||||||
if p, ok := os.LookupEnv("PORT"); ok {
|
if p, ok := os.LookupEnv("PORT"); ok {
|
||||||
@ -39,7 +39,7 @@ func main() {
|
|||||||
log.Fatal(http.ListenAndServe(port, r))
|
log.Fatal(http.ListenAndServe(port, r))
|
||||||
}
|
}
|
||||||
|
|
||||||
func webhook(w http.ResponseWriter, r *http.Request) {
|
func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
payload := ""
|
payload := ""
|
||||||
if p, err := ioutil.ReadAll(r.Body); err != nil {
|
if p, err := ioutil.ReadAll(r.Body); err != nil {
|
||||||
writeResponse(w, 500, "Internal Server Error: Could not read payload")
|
writeResponse(w, 500, "Internal Server Error: Could not read payload")
|
||||||
@ -56,7 +56,7 @@ func webhook(w http.ResponseWriter, r *http.Request) {
|
|||||||
config := Config{}
|
config := Config{}
|
||||||
json.Unmarshal(raw_config, &config)
|
json.Unmarshal(raw_config, &config)
|
||||||
|
|
||||||
// check what service is specified in URL (/webhook/{service}) and if it exists
|
// check what service is specified in URL (/webhooks/{service}) and if it exists
|
||||||
service, ok := config.Services[string(mux.Vars(r)["service"])]
|
service, ok := config.Services[string(mux.Vars(r)["service"])]
|
||||||
if !ok {
|
if !ok {
|
||||||
writeResponse(w, 404, "Service Not Found")
|
writeResponse(w, 404, "Service Not Found")
|
||||||
|
15
readme.md
15
readme.md
@ -1,10 +1,13 @@
|
|||||||
# gohookr
|
# gohookr
|
||||||
|
|
||||||
A _really_ simple webhook receiver.
|
A _really_ simple webhook receiver, which listens at `0.0.0.0:<port>/webhooks/<webhook-name>`.
|
||||||
|
|
||||||
Check config.json for an example configuration.
|
Default port is 80 and can be overriden by setting the environment variable `PORT`.
|
||||||
|
|
||||||
Default config path is `/etc/ghookr.conf`, can be overriden with `CONFIG` environment variable.
|
Default config path is `/etc/gohookr.conf` and can be overriden by setting environment variable
|
||||||
|
`CONFIG`.
|
||||||
|
|
||||||
|
Check below for an example configuration.
|
||||||
|
|
||||||
## Signature Verification
|
## Signature Verification
|
||||||
|
|
||||||
@ -15,8 +18,8 @@ You should also specify a shared secret in the `Secret` key.
|
|||||||
|
|
||||||
### Disable Signature Verification
|
### Disable Signature Verification
|
||||||
|
|
||||||
You can disable signature verification altogether by setting environment variable `NO_SIGNATURE_VERIFICATION`
|
You can disable signature verification altogether by setting environment variable
|
||||||
to `true`.
|
`NO_SIGNATURE_VERIFICATION` to `true`.
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
@ -26,7 +29,7 @@ A non-zero return code is considered a fail and gohookr will run no further test
|
|||||||
deploy.
|
deploy.
|
||||||
|
|
||||||
Tests are run in the order they're listed so any actions that need to be done before
|
Tests are run in the order they're listed so any actions that need to be done before
|
||||||
tests are run can simply be put before the tests.
|
real tests are run can simply be put before the tests.
|
||||||
|
|
||||||
## Example Config
|
## Example Config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user