Skip to content

Commit

Permalink
WIP compression
Browse files Browse the repository at this point in the history
  • Loading branch information
flrdv committed Nov 7, 2024
1 parent 76eaea1 commit 2ee9537
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/compression/compression.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
17 changes: 17 additions & 0 deletions examples/compression/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Multiple file upload</title>
</head>
<body>
<h1>Upload multiple files with fields</h1>

<form action="/upload" method="post" enctype="multipart/form-data">
Name: <input type="text" name="name"><br>
Email: <input type="email" name="email"><br>
Files: <input type="file" name="files" multiple><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 2ee9537

Please sign in to comment.