-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Where to define the interfaces please? #3
Comments
Oh, it seems that the UPDATE: the package ports
import (
"github.com/gofiber/fiber/v2"
)
type PostHandler interface {
CreatePost(ctx *fiber.Ctx) error
} and I have not been able to figured out what to put into BTW, it would be really great if the result of the 14 steps in README can be published into a branch. Thanks. |
Hi, @suntong since the interfaces are core part of the package (define the behavior of how the parts of the app should interact) they are inside of the In the case you wanna add a new context for example |
I haven't been able to make it work yet,
I put the above quoted code there, and here are what I've changed to --- a/blog/pkg/server/server.go
+++ b/blog/pkg/server/server.go
@@ -9,6 +9,7 @@ import (
"github.com/gofiber/swagger"
"github.com/golang-jwt/jwt/v4"
userHdl "backend/internal/user/domain/ports"
+ postHdl "backend/internal/post/domain/ports"
configurator "backend/pkg/config/domain/ports"
mdl "backend/pkg/middleware/domain/ports"
)
@@ -16,6 +17,7 @@ import (
type Server struct {
mdl mdl.MiddlewareHandlers
user userHdl.UserHandlers
+ postHandler postHdl.HTTPPostHandlers
configurator configurator.ConfigApplication
}
@@ -42,6 +44,7 @@ func (s *Server) Run(port string) error {
v1Private := app.Group("/api/v1").Use(s.mdl.Authenticate())
// Test Endpoint
+ v1Private.Post("/posts", s.postHandler.CreatePost)
v1Private.Get("/secret", func(c *fiber.Ctx) error {
user := c.Locals("user").(*jwt.Token)
claims := user.Claims.(jwt.MapClaims) and I'm getting
If I use
For the
Or would you put back the missing pieces and correct the mistakes in the README file please? Thanks. |
go-jwt-auth/README.md
Lines 60 to 73 in f52fb4a
Hi, I don't quite get where exactly the above interfaces code should be put -- it should be put in only one of the above three files, not all of them right? If so, which one then?
The text was updated successfully, but these errors were encountered: