diff --git a/examples/compression/compression.go b/examples/compression/compression.go new file mode 100644 index 0000000..75adfe7 --- /dev/null +++ b/examples/compression/compression.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/indigo-web/indigo" + "github.com/indigo-web/indigo/http" + "github.com/indigo-web/indigo/router/inbuilt" + "log" + "strconv" + "strings" +) + +func Shout(r *http.Request) *http.Response { + body, err := r.Body.String() + if err != nil { + return http.Error(r, err) + } + + fmt.Println(strings.ToUpper(strconv.Quote(body))) + return http.Respond(r) +} + +func main() { + app := indigo.New(":8080") + + r := inbuilt.New(). + Get("/", inbuilt.File("index.html")). + Post("/submit", Shout) + + if err := app.Serve(r); err != nil { + log.Fatal(err) + } +} diff --git a/examples/compression/index.html b/examples/compression/index.html new file mode 100644 index 0000000..d603336 --- /dev/null +++ b/examples/compression/index.html @@ -0,0 +1,17 @@ + + + + + Multiple file upload + + +

Upload multiple files with fields

+ +
+ Name:
+ Email:
+ Files:

+ +
+ + \ No newline at end of file diff --git a/go.mod b/go.mod index 40691bd..0745ec8 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/indigo-web/iter v0.1.0 github.com/indigo-web/utils v0.6.3 github.com/json-iterator/go v1.1.12 + github.com/klauspost/compress v1.17.11 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.28.0 ) diff --git a/go.sum b/go.sum index 2e5a2e7..2274440 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/indigo-web/utils v0.6.3 h1:Q8FTD8eklLv19iPQ2lQi0Mffxv9SLLab7Yq1OlMpo5 github.com/indigo-web/utils v0.6.3/go.mod h1:Q+voOJjIRN7DV+ifWozy6RY6cDF10Ev0NPDjsuOAXfQ= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=