websocket actions: Refactor registration
This commit is contained in:
parent
08ab7b4383
commit
7b5f8a9882
4 changed files with 102 additions and 87 deletions
36
internal/dis/component/server/admin/socket/proto/info.go
Normal file
36
internal/dis/component/server/admin/socket/proto/info.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth/scopes"
|
||||
)
|
||||
|
||||
// Action is anything that can be retrieved from a
|
||||
type Action struct {
|
||||
// NumPara
|
||||
NumParams int
|
||||
|
||||
// Scope and ScopeParam indicate the scope required by the caller.
|
||||
// TODO(twiesing): Once we actually include scopes, make them dynamic
|
||||
Scope component.Scope
|
||||
ScopeParam string
|
||||
|
||||
// Handle handles this action.
|
||||
//
|
||||
// ctx is closed once the underlying connection is closed.
|
||||
// out is an io.Writer that is automatically sent to the client.
|
||||
// params holds exactly NumParams parameters.
|
||||
Handle func(ctx context.Context, in io.Reader, out io.Writer, params ...string) error
|
||||
}
|
||||
|
||||
// scope returns the actual scope required by this action.
|
||||
// If the caller did not provide an actual scope, uses ScopeNever
|
||||
func (action Action) scope() component.Scope {
|
||||
if action.Scope == "" {
|
||||
return scopes.ScopeNever
|
||||
}
|
||||
return action.Scope
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue