-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
51 lines (42 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"context"
"fmt"
"net/http"
"os"
"github.com/americanas-go/config"
"github.com/americanas-go/ignite/americanas-go/log.v1"
"github.com/americanas-go/ignite/labstack/echo.v4"
logplugin "github.com/americanas-go/ignite/labstack/echo.v4/plugins/contrib/americanas-go/log.v1"
"github.com/americanas-go/ignite/labstack/echo.v4/plugins/extra/error_handler"
e "github.com/labstack/echo/v4"
)
func init() {
os.Setenv("IGNITE_ECHO_PORT", "443")
os.Setenv("IGNITE_ECHO_TLS_ENABLED", "true")
os.Setenv("IGNITE_ECHO_TLS_TYPE", "AUTO")
os.Setenv("IGNITE_ECHO_TLS_AUTO_HOST", "localhost")
os.Setenv("IGNITE_LOGRUS_CONSOLE_LEVEL", "TRACE")
}
func main() {
config.Load()
log.New()
ctx := context.Background()
srv := echo.NewServer(ctx,
logplugin.Register,
error_handler.Register)
srv.GET("/", func(c e.Context) error {
req := c.Request()
format := `
<code>
Protocol: %s<br>
Host: %s<br>
Remote Address: %s<br>
Method: %s<br>
Path: %s<br>
</code>
`
return c.HTML(http.StatusOK, fmt.Sprintf(format, req.Proto, req.Host, req.RemoteAddr, req.Method, req.URL.Path))
})
srv.Serve(ctx)
}