-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.go
52 lines (43 loc) · 1.47 KB
/
Controller.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
48
49
50
51
52
package gorest
import "net/http"
type Controller interface {
ListController
CreateController
ContextHandler
ShowController
UpdateController
DeleteController
}
type ListController interface {
// List -- GET /
// List is the endpoint that responsible to list available resources to the requester.
List(w http.ResponseWriter, r *http.Request)
}
type CreateController interface {
// Create -- POST /
// Create is expected to add a new element to the given collection.
Create(w http.ResponseWriter, r *http.Request)
}
type ShowController interface {
// Show -- GET /{resourceID}
// Show expected to retrieve a specific resource from a collection by ID
Show(w http.ResponseWriter, r *http.Request)
}
type UpdateController interface {
// Update -- PUT /{resourceID}
// Update expected to update the properties of a received resource that is identified by id.
Update(w http.ResponseWriter, r *http.Request)
}
type DeleteController interface {
// Delete -- DELETE /{resourceID}
// Delete is expected to make the resource unavailable one way or an another.
Delete(w http.ResponseWriter, r *http.Request)
}
type WithNotFoundHandler interface {
// NotFound is expected to represent a resource not found response to the requester.
NotFound(w http.ResponseWriter, r *http.Request)
}
type WithInternalServerErrorHandler interface {
// InternalServerError is expected to represent an unexpected error occurrence in the request.
InternalServerError(w http.ResponseWriter, r *http.Request)
}