Skip to content

Instantly share code, notes, and snippets.

@RayyanNafees
Forked from kimihito/index.go
Created May 30, 2024 11:34
Show Gist options
  • Select an option

  • Save RayyanNafees/d6b504ea9be92c861ebf57f074037ee8 to your computer and use it in GitHub Desktop.

Select an option

Save RayyanNafees/d6b504ea9be92c861ebf57f074037ee8 to your computer and use it in GitHub Desktop.

Revisions

  1. @kimihito kimihito revised this gist Apr 28, 2020. No changes.
  2. @kimihito kimihito created this gist Apr 28, 2020.
    27 changes: 27 additions & 0 deletions index.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // set api/index.go
    package handler

    import (
    "net/http"

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

    func hello(c echo.Context) error {
    return c.String(http.StatusOK, "Hello World")
    }

    func hello2(c echo.Context) error {
    return c.String(http.StatusOK, "Hello World2")
    }

    func Handler(w http.ResponseWriter, r *http.Request) {
    e := echo.New()
    e.Use(middleware.Logger())
    e.Use(middleware.Recover())
    e.GET("/api/", hello)
    e.GET("/api/2", hello2)

    e.ServeHTTP(w, r)
    }
    7 changes: 7 additions & 0 deletions now.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    {
    "name": "hoge",
    "version": 2,
    "routes": [
    { "src": "/api/.*", "dest": "api/index.go" }
    ]
    }