github.com/volts-dev/volts@v0.0.0-20240120094013-5e9c65924106/router/context.go (about)

     1  package router
     2  
     3  import (
     4  	"context"
     5  	"reflect"
     6  
     7  	"github.com/volts-dev/dataset"
     8  	"github.com/volts-dev/volts/internal/body"
     9  )
    10  
    11  var ContextType = reflect.TypeOf(new(IContext)).Elem()
    12  
    13  type (
    14  	TParamsSet struct {
    15  		dataset.TRecordSet
    16  		context IContext
    17  	}
    18  
    19  	IContext interface {
    20  		// pravite
    21  		setHandler(*handler)
    22  
    23  		// public
    24  		Next()
    25  		Body() *body.TBody
    26  		Data() *TParamsSet
    27  		PathParams() *TParamsSet
    28  		Write([]byte) (int, error)
    29  		WriteStream(interface{}) error
    30  		Route() route
    31  		Router() IRouter
    32  		Context() context.Context
    33  		RespondByJson(data interface{})
    34  		HandlerIndex() int
    35  		Handler(index ...int) *handler
    36  		ValueModel() reflect.Value //
    37  		TypeModel() reflect.Type
    38  		IsDone() bool //response data is done
    39  		String() string
    40  		//Abort(string)
    41  		NotFound(message ...string)
    42  	}
    43  )
    44  
    45  func NewParamsSet(hd IContext) *TParamsSet {
    46  	return &TParamsSet{
    47  		TRecordSet: *dataset.NewRecordSet(),
    48  		context:    hd,
    49  	}
    50  }