github.com/goravel/framework@v1.13.9/http/console/stubs.go (about)

     1  package console
     2  
     3  type Stubs struct {
     4  }
     5  
     6  func (r Stubs) Request() string {
     7  	return `package DummyPackage
     8  
     9  import (
    10  	"github.com/goravel/framework/contracts/http"
    11  	"github.com/goravel/framework/contracts/validation"
    12  )
    13  
    14  type DummyRequest struct {
    15  	DummyField
    16  }
    17  
    18  func (r *DummyRequest) Authorize(ctx http.Context) error {
    19  	return nil
    20  }
    21  
    22  func (r *DummyRequest) Rules(ctx http.Context) map[string]string {
    23  	return map[string]string{}
    24  }
    25  
    26  func (r *DummyRequest) Messages(ctx http.Context) map[string]string {
    27  	return map[string]string{}
    28  }
    29  
    30  func (r *DummyRequest) Attributes(ctx http.Context) map[string]string {
    31  	return map[string]string{}
    32  }
    33  
    34  func (r *DummyRequest) PrepareForValidation(ctx http.Context, data validation.Data) error {
    35  	return nil
    36  }
    37  `
    38  }
    39  
    40  func (r Stubs) Controller() string {
    41  	return `package DummyPackage
    42  
    43  import (
    44  	"github.com/goravel/framework/contracts/http"
    45  )
    46  
    47  type DummyController struct {
    48  	//Dependent services
    49  }
    50  
    51  func NewDummyController() *DummyController {
    52  	return &DummyController{
    53  		//Inject services
    54  	}
    55  }
    56  
    57  func (r *DummyController) Index(ctx http.Context) http.Response {
    58  	return nil
    59  }	
    60  `
    61  }
    62  
    63  func (r Stubs) ResourceController() string {
    64  	return r.Controller() + `
    65  func (r *DummyController) Show(ctx http.Context) http.Response {
    66  	return nil
    67  }
    68  
    69  func (r *DummyController) Store(ctx http.Context) http.Response {
    70  	return nil
    71  }
    72  
    73  func (r *DummyController) Update(ctx http.Context) http.Response {
    74  	return nil
    75  }
    76  
    77  func (r *DummyController) Destroy(ctx http.Context) http.Response {
    78  	return nil
    79  }
    80  `
    81  }
    82  
    83  func (r Stubs) Middleware() string {
    84  	return `package DummyPackage
    85  
    86  import (
    87  	"github.com/goravel/framework/contracts/http"
    88  )
    89  
    90  func DummyMiddleware() http.Middleware {
    91  	return func(ctx http.Context) {
    92  		ctx.Request().Next()
    93  	}
    94  }
    95  `
    96  }