Documentation ¶
Index ¶
- Constants
- Variables
- func ErrInvalidRequest(err error) render.Renderer
- func ErrRender(err error) render.Renderer
- func ErrServer(err error) render.Renderer
- func NewPublicationListResponse(publications []stor.Publication) []render.Renderer
- func NewUserListResponse(users []stor.User) []render.Renderer
- type Api
- type ErrResponse
- type Pagination
- type PublicationRequest
- type PublicationResponse
- type UserRequest
- type UserResponse
Constants ¶
View Source
const ERROR_BASE_URL = "http://edrlab.org/pubstore/error/"
Error types
View Source
const SERVER_ERROR = ERROR_BASE_URL + "server"
Variables ¶
View Source
var ErrNotFound = &ErrResponse{
HTTPStatusCode: 404,
Type: "about:blank",
Title: "Resource not found.",
}
Functions ¶
func ErrInvalidRequest ¶
func NewPublicationListResponse ¶
func NewPublicationListResponse(publications []stor.Publication) []render.Renderer
NewPublicationListResponse creates a rendered list of publications
Types ¶
type ErrResponse ¶
type ErrResponse struct { //not serialized Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code //mandatory Type string `json:"type"` Title string `json:"title"` //optional Detail string `json:"detail,omitempty"` // application-level error message Instance string `json:"instance,omitempty"` }
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
type Pagination ¶
Pagination defines a page and pageSize, used for api pagination
type PublicationRequest ¶
type PublicationRequest struct {
*stor.Publication
}
PublicationRequest is the request publication payload.
type PublicationResponse ¶
type PublicationResponse struct { *stor.Publication // do not serialize the following properties ID omit `json:"ID,omitempty"` CreatedAt omit `json:"CreatedAt,omitempty"` UpdatedAt omit `json:"UpdatedAt,omitempty"` DeletedAt omit `json:"DeletedAt,omitempty"` }
PublicationResponse is the response publication payload.
func NewPublicationResponse ¶
func NewPublicationResponse(pub *stor.Publication) *PublicationResponse
NewPublicationResponse creates a rendered publication.
func (*PublicationResponse) Render ¶
func (pub *PublicationResponse) Render(w http.ResponseWriter, r *http.Request) error
Render processes responses before marshalling.
type UserRequest ¶
UserRequest is the request user payload.
type UserResponse ¶
type UserResponse struct { *stor.User // do not serialize the following properties ID omit `json:"ID,omitempty"` CreatedAt omit `json:"CreatedAt,omitempty"` UpdatedAt omit `json:"UpdatedAt,omitempty"` DeletedAt omit `json:"DeletedAt,omitempty"` Password omit `json:"password,omitempty"` Passphrase omit `json:"passphrase,omitempty"` HPassword omit `json:"hpassword,omitempty"` HPassphrase omit `json:"hpassphrase,omitempty"` }
UserResponse is the response user payload.
func NewUserResponse ¶
func NewUserResponse(user *stor.User) *UserResponse
NewUserResponse creates a rendered user.
func (*UserResponse) Render ¶
func (pub *UserResponse) Render(w http.ResponseWriter, r *http.Request) error
Render processes responses before marshalling.
Click to show internal directories.
Click to hide internal directories.