danielgtaylor / danielgtaylor/huma
Question about `huma.WriteErr`
- Dominant language
- Go
- Stars
- 4.4k
- Forks
- 285
- Avg merge
- 40m
- Merged PRs (30d)
- 1
Description
In huma middleware [docs](https://huma.rocks/features/middleware/#errors).
I don't know where dose the variable `api` come from?
``` go
func MyMiddleware(ctx huma.Context, next func(ctx huma.Context)) {
// If there is a query parameter "error=true", then return an error
if ctx.Query("error") == "true" {
// WHERE DOSE THE VARIABLE API COME FROM
huma.WriteErr(api, ctx, http.StatusInternalServerError,
"Some friendly message", fmt.Errorf("error detail"),
)
return
}
// Otherwise, just continue as normal.
next(ctx)
})
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the middleware errors documentation page linked in the issue and inspect the surrounding example to determine how the api value is obtained. Update the example or its explanation so a reader knows where api comes from, then verify that the documented middleware example is self-contained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100