Skip to content

Commit

Permalink
test: trying to increase request body size
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitst05 committed May 2, 2024
1 parent 1a8ecc0 commit 785cf29
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions api/handler/srhinkHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

func HandlePNG() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand Down Expand Up @@ -47,6 +49,8 @@ func HandlePNG() http.HandlerFunc {

func HandleJPG() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand Down Expand Up @@ -84,6 +88,8 @@ func HandleJPG() http.HandlerFunc {

func HandlePDF() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand All @@ -107,6 +113,8 @@ func HandlePDF() http.HandlerFunc {

func HandleDOCX() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand Down Expand Up @@ -155,6 +163,8 @@ func HandleDOCX() http.HandlerFunc {

func HandleMP3() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand All @@ -178,6 +188,8 @@ func HandleMP3() http.HandlerFunc {

func HandleWAV() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand All @@ -201,6 +213,8 @@ func HandleWAV() http.HandlerFunc {

func HandleMP4() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand Down Expand Up @@ -251,6 +265,8 @@ func HandleMP4() http.HandlerFunc {

func HandleMKV() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)

file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, "Could not retrieve file", http.StatusBadRequest)
Expand Down
2 changes: 1 addition & 1 deletion web/templates/pages/home.templ
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ templ Home() {
<title>ShrinkIt</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script src="dist/htmx.min.js" type="application/javascript"></script>
<script src="dist/htmx.min.js" type="text/javascript"></script>
<link href="dist/style.css" rel="stylesheet"/>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion web/templates/pages/home_templ.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!doctype html><html lang=\"en\"><head><title>ShrinkIt</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script src=\"dist/htmx.min.js\" type=\"application/javascript\"></script><link href=\"dist/style.css\" rel=\"stylesheet\"></head><body><main class=\"flex flex-col items-center min-h-screen bg-[#F8F6E3] dark:bg-[#1B262C]\">
<!doctype html><html lang=\"en\"><head><title>ShrinkIt</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script src=\"dist/htmx.min.js\" type=\"text/javascript\"></script><link href=\"dist/style.css\" rel=\"stylesheet\"></head><body><main class=\"flex flex-col items-center min-h-screen bg-[#F8F6E3] dark:bg-[#1B262C]\">
<h1 class=\"flex text-6xl font-bold text-[#7AA2E3] dark:text-[#BBE1FA] mt-40 mb-10 select-none\">ShrinkIt</h1><ul id=\"cards\" hx-get=\"/cards\" hx-vals=\"js:{&#34;choice&#34;: localStorage.getItem(&#34;choice&#34;) || &#34;image&#34;}\" hx-trigger=\"load\" hx-swap=\"innerHTML\" class=\"flex flex-col md:flex-row justify-center items-center gap-16 mt-8 select-none\"><!--Will be swapped with cards--></ul></main></body></html>

0 comments on commit 785cf29

Please sign in to comment.