Documentation
¶
Index ¶
- Variables
- func ParseQueryParams(r api2go.Request, filterableFields map[string]bool, ...) (*query.Query, error)
- type PostResource
- func (s PostResource) Create(obj interface{}, r api2go.Request) (api2go.Responder, error)
- func (s PostResource) Delete(id string, r api2go.Request) (api2go.Responder, error)
- func (s PostResource) FindAll(r api2go.Request) (api2go.Responder, error)
- func (s PostResource) FindOne(id string, r api2go.Request) (api2go.Responder, error)
- func (s PostResource) PaginatedFindAll(r api2go.Request) (uint, api2go.Responder, error)
- func (s PostResource) Update(obj interface{}, r api2go.Request) (api2go.Responder, error)
- type RelationshipFunc
- type Response
- type UserResource
- func (s UserResource) Create(obj interface{}, r api2go.Request) (api2go.Responder, error)
- func (s UserResource) Delete(id string, r api2go.Request) (api2go.Responder, error)
- func (s UserResource) FindAll(r api2go.Request) (api2go.Responder, error)
- func (s UserResource) FindOne(id string, r api2go.Request) (api2go.Responder, error)
- func (s UserResource) PaginatedFindAll(r api2go.Request) (uint, api2go.Responder, error)
- func (s UserResource) Update(obj interface{}, r api2go.Request) (api2go.Responder, error)
Constants ¶
This section is empty.
Variables ¶
var PostFilterableFields = map[string]bool{ "id": true, "created-at": false, "updated-at": false, "permalink": true, }
PostFilterableFields is a map of fields a post can sort or filter by, where the key is the jsonapi field name and the value is whether a filter should be performed using strict equality (true), or using a LIKE statement (false), in the SQL generated for the query
var PostRelationships = map[string]RelationshipFunc{
"usersID": getPostsByUsersID,
}
PostRelationships defines the functions for modifying a Query to select...
var UserFilterableFields = map[string]bool{ "id": true, "created-at": false, "updated-at": false, "email": true, "username": true, }
UserFilterableFields is a map of fields a user can sort or filter by, where the key is the jsonapi field name and the value is whether a filter should be performed using strict equality (true), or using a LIKE statement (false), in the SQL generated for the query
var UserRelationshipsByParam = map[string]RelationshipFunc{
"postsID": getUsersByPostsID,
}
UserRelationshipsByParam defines a map where the key is the query param and the function is the RelationshipFunc for modifying the query to get the given relationship
Functions ¶
Types ¶
type PostResource ¶
type PostResource struct {
PostStorage *storage.PostStorage
}
PostResource defines interface to storage layer
func (PostResource) FindOne ¶
FindOne to satisfy `api2go.DataSource` interface this method should return the post with the given ID, otherwise an error
func (PostResource) PaginatedFindAll ¶
PaginatedFindAll can be used to load posts in chunks
type RelationshipFunc ¶
RelationshipFunc defines the function type for modifying a Query to select a relationship
type Response ¶
type Response struct { Res interface{} Code int }
Implementation of api2go.Responder
func (Response) StatusCode ¶
StatusCode returns the HTTP status code
type UserResource ¶
type UserResource struct {
UserStorage *storage.UserStorage
}
UserResource defines interface to storage layer
func (UserResource) FindOne ¶
FindOne to satisfy `api2go.DataSource` interface this method should return the user with the given ID, otherwise an error
func (UserResource) PaginatedFindAll ¶
PaginatedFindAll can be used to load users in chunks