mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-06-12 17:47:14 +02:00
chore(runner): add new token in header
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
@ -77,3 +77,21 @@ func WithUUIDHeader(uuid string) Option {
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// WithTokenHeader add runner token in header
|
||||
func WithTokenHeader(token string) Option {
|
||||
return OptionFunc(func(cfg *config) {
|
||||
if token == "" {
|
||||
return
|
||||
}
|
||||
cfg.opts = append(
|
||||
cfg.opts,
|
||||
connect.WithInterceptors(connect.UnaryInterceptorFunc(func(next connect.UnaryFunc) connect.UnaryFunc {
|
||||
return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) {
|
||||
req.Header().Set(core.TokenHeader, token)
|
||||
return next(ctx, req)
|
||||
}
|
||||
})),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user