mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-03-29 20:37:58 -04:00
🔧 fix(handlers_web.go): fix typo in handleAttribute function name
✨ feat(handlers_web.go): add new route handlers for /point/:id and /attr/:id endpoints to handle attribute requests
This commit is contained in:
parent
0f745c1a25
commit
ae8534a693
@ -114,6 +114,22 @@ func (s *Server) handleService(c *fiber.Ctx) error {
|
|||||||
}, "base")
|
}, "base")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) handleAttribute(c *fiber.Ctx) error {
|
||||||
|
attributeId := strings.ToLower(c.Params("id"))
|
||||||
|
|
||||||
|
// Get service from database by name
|
||||||
|
attribute := database.ServiceAttributes.GetAttribute(attributeId)
|
||||||
|
|
||||||
|
// Get all services that have this attribute
|
||||||
|
services := database.Client.Service.Query().Where(service.AttributesContains(attributeId)).Where(service.Pending(false), service.Listed(true)).AllX(context.Background())
|
||||||
|
|
||||||
|
return c.Render("attribute", fiber.Map{
|
||||||
|
"Title": fmt.Sprintf("%v | Attribute", attribute.ID),
|
||||||
|
"Attribute": attribute,
|
||||||
|
"Services": services,
|
||||||
|
}, "base")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) handleRequestServiceForm(c *fiber.Ctx) error {
|
func (s *Server) handleRequestServiceForm(c *fiber.Ctx) error {
|
||||||
challenge, id, difficulty, err := s.PowChallenger.PowGenerateChallenge(16)
|
challenge, id, difficulty, err := s.PowChallenger.PowGenerateChallenge(16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -83,6 +83,8 @@ func (s *Server) RegisterRoutes() {
|
|||||||
// Register HTTP route for getting initial state.
|
// Register HTTP route for getting initial state.
|
||||||
s.Router.Get("/", s.handleIndex)
|
s.Router.Get("/", s.handleIndex)
|
||||||
s.Router.Get("/service/:name", s.handleService)
|
s.Router.Get("/service/:name", s.handleService)
|
||||||
|
s.Router.Get("/point/:id", s.handleAttribute)
|
||||||
|
s.Router.Get("/attr/:id", s.handleAttribute)
|
||||||
s.Router.Get("/request/service", s.handleRequestServiceForm)
|
s.Router.Get("/request/service", s.handleRequestServiceForm)
|
||||||
s.Router.Post("/request/service", s.handleRequestServicePostForm)
|
s.Router.Post("/request/service", s.handleRequestServicePostForm)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user