orders
This commit is contained in:
26
controllers/appRequest.go
Normal file
26
controllers/appRequest.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
// isAppRequest reports whether a request arrived on the customer app's base.
|
||||
//
|
||||
// Several handlers are registered on both `/v1/web/...` and `/v1/mob/...`, and
|
||||
// a few of them owe the two callers different answers. The clearest case is
|
||||
// stock: the console lists a product with an empty shelf so a merchant can
|
||||
// refill it, and the app must not list the same product at all, because a
|
||||
// shopper can only choose it and be refused at checkout.
|
||||
//
|
||||
// The base is read from the path rather than passed down through the service,
|
||||
// so the difference stays where it belongs — at the edge, in the one place that
|
||||
// knows which audience asked. Services keep answering the same question the
|
||||
// same way for everyone.
|
||||
//
|
||||
// Matched with the surrounding slashes so a tenant, product or keyword
|
||||
// containing "mob" cannot make a console request look like an app one.
|
||||
func isAppRequest(c *fiber.Ctx) bool {
|
||||
return strings.Contains(c.Path(), "/v1/mob/")
|
||||
}
|
||||
Reference in New Issue
Block a user