-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
25 lines (20 loc) · 670 Bytes
/
api.go
File metadata and controls
25 lines (20 loc) · 670 Bytes
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
package api
import "net/http"
// Here we define the structs and the
//User defines a user
type User struct {
ID int64
Firstname string
Lastname string
}
// UserStorageService describes the methods required to handle the storage of the users
type UserStorageService interface {
Get(id int64) (*User, error)
Query(queryFilter interface{}) ([]*User, error)
Create(u *User) error
Update(u *User) error
Delete(id int64) error
}
// QueryFilterFromHTTPRequest is the method called by the HTTP handler
// to generate the queryFilter passed to the query func of each storage service
type QueryFilterFromHTTPRequest func(r *http.Request) (interface{}, error)