Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions frameworks/echo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.26-alpine AS build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY main.go ./
RUN CGO_ENABLED=0 go build -o server main.go

FROM alpine:3.23
COPY --from=build /app/server /server
EXPOSE 8080
CMD ["/server"]
25 changes: 25 additions & 0 deletions frameworks/echo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# echo

Echo v4 on the Go `net/http` server, default configuration.

## Stack

- **Language:** Go 1.26
- **Framework:** Echo v4
- **Build:** `golang:1.26-alpine` -> `alpine:3.23` runtime

## Endpoints

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/pipeline` | GET | Returns `ok` (plain text) |
| `/baseline11` | GET | Sums query parameter values |
| `/baseline11` | POST | Sums query parameters + request body |
| `/json/{count}?m=N` | GET | First `count` dataset items with `total = price * quantity * m` |
| `/upload` | POST | Reads the body and returns the byte count |

## Notes

- Routing and path parameters through the Echo router, JSON through `c.JSON`
- Compression through the Echo `Gzip` middleware
- Banner and port log disabled, no other middleware installed
18 changes: 18 additions & 0 deletions frameworks/echo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module httparena/echo

go 1.25.0

require github.com/labstack/echo/v4 v4.15.4

require (
github.com/labstack/gommon v0.5.0 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.53.0 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/text v0.38.0 // indirect
golang.org/x/time v0.15.0 // indirect
)
30 changes: 30 additions & 0 deletions frameworks/echo/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/labstack/echo/v4 v4.15.4 h1:DL45vVYa+BWE+XuW+zZNd9H0YEdZ80UAWJGcTVW4EVs=
github.com/labstack/echo/v4 v4.15.4/go.mod h1:CuMetKIRwsuO/qlAgMq+KTAalwGoB/h4tC+yPdrTj1g=
github.com/labstack/gommon v0.5.0 h1:6VSQ2NOzsnEJ5W6+84E0RbcaDDmgB6NIAzWCczTEe6c=
github.com/labstack/gommon v0.5.0/go.mod h1:Rzlg7HHy1maLfzBYGg9NZcVuz1sA68HHhLjhcEllYE0=
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
123 changes: 123 additions & 0 deletions frameworks/echo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package main

import (
"encoding/json"
"io"
"net/http"
"os"
"strconv"
"strings"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)

type Rating struct {
Score int `json:"score"`
Count int `json:"count"`
}

type DatasetItem struct {
ID int `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
Price int `json:"price"`
Quantity int `json:"quantity"`
Active bool `json:"active"`
Tags []string `json:"tags"`
Rating Rating `json:"rating"`
}

type ProcessedItem struct {
DatasetItem
Total int `json:"total"`
}

type ProcessResponse struct {
Items []ProcessedItem `json:"items"`
Count int `json:"count"`
}

var dataset []DatasetItem

func loadDataset() {
path := os.Getenv("DATASET_PATH")
if path == "" {
path = "/data/dataset.json"
}
data, err := os.ReadFile(path)
if err != nil {
return
}
json.Unmarshal(data, &dataset)
}

func pipeline(c echo.Context) error {
return c.String(http.StatusOK, "ok")
}

func baseline11(c echo.Context) error {
sum := 0
for _, values := range c.QueryParams() {
for _, v := range values {
if n, err := strconv.Atoi(v); err == nil {
sum += n
}
}
}
if c.Request().Method == http.MethodPost {
body, err := io.ReadAll(c.Request().Body)
if err == nil {
if n, err := strconv.Atoi(strings.TrimSpace(string(body))); err == nil {
sum += n
}
}
}
return c.String(http.StatusOK, strconv.Itoa(sum))
}

func jsonItems(c echo.Context) error {
count, _ := strconv.Atoi(c.Param("count"))
if count < 0 {
count = 0
}
if count > len(dataset) {
count = len(dataset)
}
m, err := strconv.Atoi(c.QueryParam("m"))
if err != nil || m == 0 {
m = 1
}

items := make([]ProcessedItem, count)
for i := 0; i < count; i++ {
d := dataset[i]
items[i] = ProcessedItem{DatasetItem: d, Total: d.Price * d.Quantity * m}
}
return c.JSON(http.StatusOK, ProcessResponse{Items: items, Count: count})
}

func upload(c echo.Context) error {
size, err := io.Copy(io.Discard, c.Request().Body)
if err != nil {
return c.String(http.StatusBadRequest, "0")
}
return c.String(http.StatusOK, strconv.FormatInt(size, 10))
}

func main() {
loadDataset()

e := echo.New()
e.HideBanner = true
e.HidePort = true
e.Use(middleware.Gzip())

e.GET("/pipeline", pipeline)
e.GET("/baseline11", baseline11)
e.POST("/baseline11", baseline11)
e.GET("/json/:count", jsonItems)
e.POST("/upload", upload)

e.Logger.Fatal(e.Start(":8080"))
}
19 changes: 19 additions & 0 deletions frameworks/echo/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"display_name": "echo",
"language": "Go",
"type": "flagship",
"mode": "standard",
"engine": "net/http",
"description": "Echo v4 on the Go net/http server, default configuration. Routing and path/query binding through the Echo API, encoding/json via c.JSON, gzip through the Echo Gzip middleware.",
"repo": "https://github.com/labstack/echo",
"enabled": true,
"tests": [
"baseline",
"pipelined",
"limited-conn",
"json",
"json-comp",
"upload"
],
"maintainers": []
}
8 changes: 8 additions & 0 deletions site/data/frameworks.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@
"engine": "zerg",
"mode": "standard"
},
"echo": {
"dir": "echo",
"description": "Echo v4 on the Go net/http server, default configuration. Routing and path/query binding through the Echo API, encoding/json via c.JSON, gzip through the Echo Gzip middleware.",
"repo": "https://github.com/labstack/echo",
"type": "flagship",
"engine": "net/http",
"mode": "standard"
},
"effinitive": {
"dir": "effinitive",
"description": "Ultra-high-performance custom HTTP server for .NET 10 \u2014 built from scratch for maximum speed.",
Expand Down
Loading