API extension points (#473)

* API endpoint extensions working.

extensions example.

* Added server.NewEnv and some docs for the API extensions example.

extensions example.
example main.go.

* Uncommented special handler stuff.

* Added section in docs for extending API linking to example main.go.

* Commented out special_handler test

* Changed to NewFromEnv
This commit is contained in:
Travis Reeder
2017-01-30 12:14:28 -08:00
committed by GitHub
parent dd052d4503
commit d5116397b6
16 changed files with 256 additions and 108 deletions

21
main.go
View File

@@ -2,31 +2,14 @@ package main
import (
"context"
"os"
log "github.com/Sirupsen/logrus"
"github.com/iron-io/functions/api/datastore"
"github.com/iron-io/functions/api/mqs"
"github.com/iron-io/functions/api/server"
"github.com/spf13/viper"
)
func main() {
ctx := contextWithSignal(context.Background(), os.Interrupt)
ctx := context.Background()
ds, err := datastore.New(viper.GetString(server.EnvDBURL))
if err != nil {
log.WithError(err).Fatalln("Invalid DB url.")
}
mq, err := mqs.New(viper.GetString(server.EnvMQURL))
if err != nil {
log.WithError(err).Fatal("Error on init MQ")
}
apiURL := viper.GetString(server.EnvAPIURL)
funcServer := server.New(ctx, ds, mq, apiURL)
funcServer := server.NewFromEnv(ctx)
// Setup your custom extensions, listeners, etc here
funcServer.Start(ctx)
}