From ef8cb0d6747f031aa824171126bf9d2a4a1da0e6 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 9 Mar 2024 11:25:54 +0800 Subject: [PATCH] Gop_Env --- classfile_v2.go | 1 + context.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/classfile_v2.go b/classfile_v2.go index e4cd146..04afd61 100644 --- a/classfile_v2.go +++ b/classfile_v2.go @@ -25,6 +25,7 @@ type Handler struct { Context } +// Main is required by Go+ compiler as the entry of a YAP HTTP handler. func (p *Handler) Main(ctx *Context) { p.Context = *ctx } diff --git a/context.go b/context.go index 87ad79f..ef5c45b 100644 --- a/context.go +++ b/context.go @@ -37,6 +37,14 @@ func (p *Context) setParam(name, val string) { p.Form.Set(name, val) } +// Gop_Env returns the value associated with the name. +// If the name exists in URL query, it returns the first value for the name. +func (p *Context) Gop_Env(name string) string { + return p.Param(name) +} + +// Param returns the value associated with the name. +// If the name exists in URL query, it returns the first value for the name. func (p *Context) Param(name string) string { return p.FormValue(name) }