mirror of
https://codeberg.org/pluja/kycnot.me
synced 2024-10-01 01:05:59 -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")
|
||||
}
|
||||
|
||||
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 {
|
||||
challenge, id, difficulty, err := s.PowChallenger.PowGenerateChallenge(16)
|
||||
if err != nil {
|
||||
|
@ -83,6 +83,8 @@ func (s *Server) RegisterRoutes() {
|
||||
// Register HTTP route for getting initial state.
|
||||
s.Router.Get("/", s.handleIndex)
|
||||
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.Post("/request/service", s.handleRequestServicePostForm)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user