Headers
// Register the route...
app.Get("/", handler)
func handler(ctx iris.Context) {
requestID := ctx.GetHeader("X-Request-Id")
authentication := ctx.GetHeader("Authentication")
}Bind
type myHeaders struct {
RequestID string `header:"X-Request-Id,required"`
Authentication string `header:"Authentication,required"`
}func handler(ctx iris.Context) {
var hs myHeaders
if err := ctx.ReadHeaders(&hs); err != nil {
ctx.StopWithError(iris.StatusInternalServerError, err)
return
}
ctx.JSON(hs)
}Last updated
Was this helpful?