listeners and special handlers improvements (#412)

* listeners and special handlers improvements

* update runnerListener methods

* typo
This commit is contained in:
Pedro Nasser
2016-12-13 16:40:48 -02:00
committed by C Cirello
parent 2fd8570e45
commit 2a09a1c2a2
10 changed files with 207 additions and 168 deletions

View File

@@ -28,8 +28,8 @@ func (c *myCustomListener) AfterAppCreate(ctx context.Context, app *models.App)
func (c *myCustomListener) BeforeAppUpdate(ctx context.Context, app *models.App) error { return nil }
func (c *myCustomListener) AfterAppUpdate(ctx context.Context, app *models.App) error { return nil }
func (c *myCustomListener) BeforeAppDelete(ctx context.Context, appName string) error { return nil }
func (c *myCustomListener) BeforeAppDelete(ctx context.Context, appName string) error { return nil }
func (c *myCustomListener) BeforeAppDelete(ctx context.Context, app *models.App) error { return nil }
func (c *myCustomListener) BeforeAppDelete(ctx context.Context, app *models.App) error { return nil }
function main () {
srv := server.New(/* Here all required parameters to initialize the server */)
@@ -42,12 +42,14 @@ function main () {
}
```
#### Listener Requirements
To be a valid listener your struct should respect interfaces combined or alone found in the file [listeners.go](/iron-io/functions/blob/master/api/ifaces/listeners.go)
### Creating a Listener
These are all available listeners:
#### App Listeners
To be a valid listener your struct should respect interfaces combined or alone found [in this file](/iron-io/functions/blob/master/api/server/apps_listeners.go)
##### AppCreateListener
_Triggers before and after every app creation that happens in the API_
@@ -71,7 +73,20 @@ _Triggers before and after every app deletion that happens in the API_
Triggered during requests to the following routes:
- DELETE /v1/apps/app
- DELETE /v1/apps/:app
#### Runner Listeners
To be a valid listener your struct should respect interfaces combined or alone found [in this file](/iron-io/functions/blob/master/api/server/runner_listeners.go).
##### RunnerListener
_Triggers before and after every function run_
Triggered during requests to the following routes:
- GET /r/:app/:route
- POST /r/:app/:route
## Special Handlers