From 30e31e546f88bf52786caca19d8b304f9ae1b249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C6=B0=E1=BB=9Bc=20Trung?= Date: Tue, 9 Aug 2022 16:37:29 +0700 Subject: [PATCH] Fires 404 HTTP Code when use gRPC strict mode --- mvc/grpc.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mvc/grpc.go b/mvc/grpc.go index e3cbe86f4a..34f9c87b64 100644 --- a/mvc/grpc.go +++ b/mvc/grpc.go @@ -47,7 +47,14 @@ func (g GRPC) Apply(c *ControllerActivator) { return } - // If strict was false, allow common HTTP clients, consumes and produces JSON. + // If strict was true fires 404 on common HTTP clients. + if g.Strict { + ctx.NotFound() + ctx.StopExecution() + return + } + + // Allow common HTTP clients, consumes and produces JSON. ctx.Next() }