Skip to content

Commit 323a170

Browse files
committed
add config
1 parent 67ff017 commit 323a170

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ go get github.com/jpascal/graphql-upload
2121
Schema: schema.New(),
2222
Context: request.Context,
2323
})
24+
}, &handler.Config {
25+
MaxBodySize: 1024
2426
}),
2527
}
2628
server.ListenAndServe()

handler.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ type File struct {
6262
Size int64
6363
}
6464

65+
type Config struct {
66+
MaxBodySize int64
67+
}
68+
6569
type Executor func(request *Request) interface{}
6670
type Factory func(http.ResponseWriter, *http.Request) interface{}
6771

68-
func New(executor Executor) *Handler {
72+
func New(executor Executor, config *Config) *Handler {
6973
return &Handler{
70-
MaxBodySize: 1024,
74+
MaxBodySize: config.MaxBodySize,
7175
Executor: executor,
7276
}
7377
}

handler_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ func TestHandler(t *testing.T) {
102102
Schema: Schema(),
103103
Context: request.Context,
104104
})
105+
}, &Config{
106+
MaxBodySize: 1024,
105107
});
106108
t.Run("GET Regular", func(t *testing.T) {
107109
req, err := http.NewRequest("GET", "/", nil)

0 commit comments

Comments
 (0)