-
Notifications
You must be signed in to change notification settings - Fork 68
/
request.go
47 lines (39 loc) · 1.23 KB
/
request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package http
import (
"net/http"
"github.com/goravel/framework/contracts/filesystem"
"github.com/goravel/framework/contracts/validation"
)
//go:generate mockery --name=Request
type Request interface {
Header(key, defaultValue string) string
Headers() http.Header
Method() string
Path() string
Url() string
FullUrl() string
Ip() string
//Input Retrieve an input item from the request: /users/{id}
Input(key string) string
// Query Retrieve a query string item form the request: /users?id=1
Query(key, defaultValue string) string
QueryArray(key string) []string
QueryMap(key string) map[string]string
// Form Retrieve a form string item form the post: /users POST:id=1
Form(key, defaultValue string) string
Bind(obj any) error
File(name string) (filesystem.File, error)
AbortWithStatus(code int)
AbortWithStatusJson(code int, jsonObj any)
Next()
Origin() *http.Request
Validate(rules map[string]string, options ...validation.Option) (validation.Validator, error)
ValidateRequest(request FormRequest) (validation.Errors, error)
}
type FormRequest interface {
Authorize(ctx Context) error
Rules() map[string]string
Messages() map[string]string
Attributes() map[string]string
PrepareForValidation(data validation.Data)
}