Add context
This commit adds and passes context around to (almost) every function. This allows cancelling (almost) every function call globally.
This commit is contained in:
parent
996ecb9f80
commit
3455f491ca
104 changed files with 836 additions and 511 deletions
|
|
@ -28,11 +28,11 @@ type Info struct {
|
|||
|
||||
func (*Info) Routes() []string { return []string{"/dis/"} }
|
||||
|
||||
func (info *Info) Handler(route string, context context.Context, io stream.IOStream) (handler http.Handler, err error) {
|
||||
func (info *Info) Handler(ctx context.Context, route string, io stream.IOStream) (handler http.Handler, err error) {
|
||||
router := mux.NewRouter()
|
||||
{
|
||||
socket := &httpx.WebSocket{
|
||||
Context: context,
|
||||
Context: ctx,
|
||||
Fallback: router,
|
||||
Handler: info.serveSocket,
|
||||
}
|
||||
|
|
@ -82,12 +82,12 @@ func (info *Info) Handler(route string, context context.Context, io stream.IOStr
|
|||
}
|
||||
|
||||
// get the instance
|
||||
instance, err := info.Instances.WissKI(r.PostFormValue("slug"))
|
||||
instance, err := info.Instances.WissKI(r.Context(), r.PostFormValue("slug"))
|
||||
if err != nil {
|
||||
return "", httpx.ErrNotFound
|
||||
}
|
||||
|
||||
target, err := instance.Users().Login(nil, r.PostFormValue("user"))
|
||||
target, err := instance.Users().Login(r.Context(), nil, r.PostFormValue("user"))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue