-
Notifications
You must be signed in to change notification settings - Fork 8
/
router.go
34 lines (27 loc) · 1009 Bytes
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Package eventgrid aims to provide a shim for easily working with Event Grid
// from a gobuffalo application. It will frequently be utilized by the code
// generated for extending your app to receive Event Grid Events.
package eventgrid
import (
"path"
"github.com/gobuffalo/buffalo"
)
// EventTypeWildcard is a special-case value that can be used when subscribing
// to an EventGrid topic.
const EventTypeWildcard = "all"
// App extends the functionality of a normal buffalo.App with actions
// specific to Event Grid. Specifically, it seeks to allow quick and easy
// register a Group of actions for processing and reasoning.
type App buffalo.App
// Subscriber creates a group of mappings (*buffalo.App) between
// a Subscriber interface implementation and the appropriate REST
// paths.
func (a *App) Subscriber(p string, s Subscriber) *buffalo.App {
g := (*buffalo.App)(a).Group(p)
p = "/"
g.POST(p, s.Receive)
if a.Env == "development" {
g.GET(path.Join(p, "new"), s.New)
}
return g
}