mirror of
				https://github.com/labstack/echo.git
				synced 2025-10-30 23:57:38 +02:00 
			
		
		
		
	Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
		
							
								
								
									
										2
									
								
								bind.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								bind.go
									
									
									
									
									
								
							| @@ -23,7 +23,7 @@ type ( | ||||
| 	// BindUnmarshaler is the interface used to wrap the UnmarshalParam method. | ||||
| 	BindUnmarshaler interface { | ||||
| 		// UnmarshalParam decodes and assigns a value from an form or query param. | ||||
| 		UnmarshalParam(src string) error | ||||
| 		UnmarshalParam(param string) error | ||||
| 	} | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -90,13 +90,17 @@ func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (w *gzipResponseWriter) WriteHeader(code int) { | ||||
| 	if code != http.StatusNoContent { // Issue #489 | ||||
| 		w.ResponseWriter.Header().Set(echo.HeaderContentEncoding, gzipScheme) | ||||
| 	} | ||||
| 	w.ResponseWriter.WriteHeader(code) | ||||
| } | ||||
|  | ||||
| func (w *gzipResponseWriter) Write(b []byte) (int, error) { | ||||
| 	if w.Header().Get(echo.HeaderContentType) == "" { | ||||
| 		w.Header().Set(echo.HeaderContentType, http.DetectContentType(b)) | ||||
| 	} | ||||
| 	if w.Header().Get(echo.HeaderContentEncoding) == "" { | ||||
| 		w.Header().Set(echo.HeaderContentEncoding, gzipScheme) | ||||
| 	} | ||||
| 	return w.Writer.Write(b) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -27,11 +27,11 @@ func TestGzip(t *testing.T) { | ||||
|  | ||||
| 	// Gzip | ||||
| 	req, _ = http.NewRequest(echo.GET, "/", nil) | ||||
| 	req.Header.Set(echo.HeaderAcceptEncoding, "gzip") | ||||
| 	req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme) | ||||
| 	rec = httptest.NewRecorder() | ||||
| 	c = e.NewContext(req, rec) | ||||
| 	h(c) | ||||
| 	assert.Equal(t, "gzip", rec.Header().Get(echo.HeaderContentEncoding)) | ||||
| 	assert.Equal(t, gzipScheme, rec.Header().Get(echo.HeaderContentEncoding)) | ||||
| 	assert.Contains(t, rec.Header().Get(echo.HeaderContentType), echo.MIMETextPlain) | ||||
| 	r, err := gzip.NewReader(rec.Body) | ||||
| 	defer r.Close() | ||||
| @@ -45,6 +45,7 @@ func TestGzip(t *testing.T) { | ||||
| func TestGzipNoContent(t *testing.T) { | ||||
| 	e := echo.New() | ||||
| 	req, _ := http.NewRequest(echo.GET, "/", nil) | ||||
| 	req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme) | ||||
| 	rec := httptest.NewRecorder() | ||||
| 	c := e.NewContext(req, rec) | ||||
| 	h := Gzip()(func(c echo.Context) error { | ||||
| @@ -64,6 +65,7 @@ func TestGzipErrorReturned(t *testing.T) { | ||||
| 		return echo.ErrNotFound | ||||
| 	}) | ||||
| 	req, _ := http.NewRequest(echo.GET, "/", nil) | ||||
| 	req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme) | ||||
| 	rec := httptest.NewRecorder() | ||||
| 	e.ServeHTTP(rec, req) | ||||
| 	assert.Equal(t, http.StatusNotFound, rec.Code) | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
|           <h1>{{ .Site.Data.index.heading }}</h1> | ||||
|           <h2>{{ .Site.Data.index.description }}</h2> | ||||
|           <p> | ||||
|             <img style="width: 100%;" src="/images/echo_terminal.png" alt="Echo"> | ||||
|             <img style="width: 100%;" src="/images/terminal.png" alt="Echo"> | ||||
|           </p> | ||||
|         </div> | ||||
|  | ||||
|   | ||||
| @@ -5,16 +5,18 @@ | ||||
|   <meta http-equiv="x-ua-compatible" content="ie=edge"> | ||||
|   <meta name="description" content="{{ if ne .URL "/" }}{{ .Description }} | {{ end }}{{ .Site.Params.description }}"> | ||||
|   <meta name="viewport" content="width=device-width, initial-scale=1"> | ||||
|   <meta name="twitter:card" content="summary"> | ||||
|   <meta name="twitter:card" content="summary_large_image"> | ||||
|   <meta name="twitter:site" content="@echo"> | ||||
|   <meta name="twitter:creator" content="@labstack"> | ||||
|   <meta name="twitter:title" content="{{ if ne .URL "/" }}{{ .Title }} | {{ end }}{{ .Site.Title }}"> | ||||
|   <meta name="twitter:description" content="{{ if ne .URL "/" }}{{ .Description }} | {{ end }}{{ .Site.Params.description }}"> | ||||
|   <meta name="twitter:image" content="{{ .Site.BaseURL }}/images/logo.png"> | ||||
|   <meta name="twitter:image" content="{{ .Site.BaseURL }}/images/share.png"> | ||||
|   <meta property="og:type" content="website"> | ||||
|   <meta property="og:site_name" content="{{ .Title }}"> | ||||
|   <meta property="og:title" content="{{ if ne .URL "/" }}{{ .Title }} | {{ end }}{{ .Site.Title }}"> | ||||
|   <meta property="og:site_name" content="echo"> | ||||
|   <meta property="og:description" content="{{ if ne .URL "/" }}{{ .Description }} | {{ end }}{{ .Site.Params.description }}"> | ||||
|   <meta property="og:url" content="{{ .Site.BaseURL }}"> | ||||
|   <meta property="og:image" content="{{ .Site.BaseURL }}/images/logo.png"> | ||||
|   <meta property="og:image" content="{{ .Site.BaseURL }}/images/share.png"> | ||||
|   <title> | ||||
|     {{ if ne .URL "/" }}{{ .Title }} | {{ end }}{{ .Site.Title }} | ||||
|   </title> | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| <!--<div class="w3-panel w3-pale-red w3-leftbar w3-border-red"> | ||||
| <div class="w3-panel w3-pale-green w3-leftbar w3-border-green"> | ||||
|   <h3> | ||||
|     Check out our new project <a href="https://github.com/labstack/armor">Armor</a> | ||||
|     Check out our new project <a href="https://armor.labstack.com">Armor</a> | ||||
|   </h3> | ||||
|   <p> | ||||
|     Uncomplicated HTTP server, supports HTTP/2 and auto TLS | ||||
|     Uncomplicated, modern HTTP server, supports HTTP/2 and auto TLS | ||||
|   </p> | ||||
| </div>--> | ||||
| </div> | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								website/static/images/share.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								website/static/images/share.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 23 KiB | 
| Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB | 
| @@ -0,0 +1 @@ | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user