File tree 2 files changed +16
-6
lines changed
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 1
1
package gql
2
2
3
3
import (
4
- "net/http"
5
4
6
5
"github.com/graphql-go/handler"
6
+ "github.com/labstack/echo/v4"
7
7
"github.com/lai0xn/squid-tech/internal/middlewares/gql"
8
8
)
9
9
10
- func Execute () {
10
+ func Execute (e * echo. Echo ) {
11
11
h := handler .New (& handler.Config {
12
12
Schema : & Schema ,
13
13
Pretty : true ,
14
14
GraphiQL : true ,
15
15
Playground : true ,
16
16
})
17
- s := http .NewServeMux ()
18
17
19
- s .Handle ("/graphql" ,middlewares .HeaderMiddleware (h ))
20
- http .ListenAndServe (":5000" , s )
18
+ e .GET ("/graphql" ,func (c echo.Context ) error {
19
+ m := middlewares .HeaderMiddleware (h )
20
+ m .ServeHTTP (c .Response (),c .Request ())
21
+ return nil
22
+
23
+ })
24
+
25
+ e .POST ("/graphql" ,func (c echo.Context ) error {
26
+ m := middlewares .HeaderMiddleware (h )
27
+ m .ServeHTTP (c .Response (),c .Request ())
28
+ return nil
29
+
30
+ })
21
31
22
32
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ func (s *Server) Setup(e *echo.Echo) {
40
40
func (s * Server ) Run () {
41
41
e := echo .New ()
42
42
s .Setup (e )
43
+ gql .Execute (e )
43
44
logger .LogInfo ().Msg ("graphql server running on port 5000" )
44
- go gql .Execute ()
45
45
logger .LogInfo ().Msg (e .Start (s .PORT ).Error ())
46
46
}
You can’t perform that action at this time.
0 commit comments