option.go 493 B

1234567891011121314151617181920212223
  1. package middleware
  2. import "context"
  3. type Option struct {
  4. GenHttp bool
  5. NotAuth bool
  6. OperationRecord bool
  7. Path string
  8. Method string
  9. AuthorizationsName string
  10. }
  11. type httpOption struct{}
  12. func NewOptionContext(ctx context.Context, op *Option) context.Context {
  13. return context.WithValue(ctx, httpOption{}, op)
  14. }
  15. func FromOptionContext(ctx context.Context) (*Option, bool) {
  16. op, ok := ctx.Value(httpOption{}).(*Option)
  17. return op, ok
  18. }