add server option to limit request size (#320)

we're going to want to do this in our service version of this thing, but
adding this here so that it's usable by everyone. just an option, can add it
to server configuration, but response is nicely formatted, etc.

closes #277
This commit is contained in:
Reed Allman
2017-09-18 22:34:19 -07:00
committed by Travis Reeder
parent c6f9b50afe
commit f335d34636
2 changed files with 44 additions and 3 deletions

View File

@@ -50,7 +50,7 @@ type Server struct {
}
// NewFromEnv creates a new Functions server based on env vars.
func NewFromEnv(ctx context.Context) *Server {
func NewFromEnv(ctx context.Context, opts ...ServerOption) *Server {
ds, err := datastore.New(viper.GetString(EnvDBURL))
if err != nil {
logrus.WithError(err).Fatalln("Error initializing datastore.")
@@ -69,7 +69,7 @@ func NewFromEnv(ctx context.Context) *Server {
}
}
return New(ctx, ds, mq, logDB)
return New(ctx, ds, mq, logDB, opts...)
}
// New creates a new Functions server with the passed in datastore, message queue and API URL