Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrorTypeInternal = iota ErrorTypeService ErrorTypeAuth )
Variables ¶
View Source
var (
ErrorProfileNotFound = errors.New("profile not found")
)
View Source
var (
ErrorUserNotInContext = errors.New("no user in context")
)
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { Id int `json:"id"` Slug string `json:"slug"` Title string `json:"title"` Description string `json:"description"` Body string `json:"body"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Author Profile `json:"author"` }
Article represents a single article
type ArticleListFilter ¶
type ArticleListFilter struct { CurrentUser *User // used for favorites and following filtering Author *Profile Limit uint64 Offset uint64 }
func NewArticleListFilter ¶
func NewArticleListFilter() ArticleListFilter
NewArticleListFilter creates filter with default values
func (ArticleListFilter) Validate ¶
func (f ArticleListFilter) Validate() error
type ArticleServiceConfig ¶
type ArticleServiceConfig struct { Type string `default:"postgres"` DSN string `default:"postgres://postgres:postgres@postgres/conduit?sslmode=disable"` Secret string }
ArticleServiceConfig describes configuration for ArticleService
type Profile ¶
type Profile struct { Id int `json:"id"` Name string `json:"username"` Bio string `json:"bio"` Image string `json:"image"` // base64 encoded Following bool `json:"following"` // set for authenticated users }
Profile is a public user info with restricted set of fields
func ProfileFromUser ¶
ProfileFromUser converts User type to Profile. It sets Following field to false because it must be calculated by caller.
type ProfileResponse ¶
type ProfileResponse struct {
Profile Profile `json:"profile"`
}
ProfileResponse is a structure returned in profile handlers
type User ¶
type User struct { Id int `json:"id"` Name string `json:"username"` Email string `json:"email"` Bio string `json:"bio,omitempty"` // Image is base64-encoded user avatar Image string `json:"image,omitempty"` // Token is JWT returned by user register, login and update Token string `json:"token,omitempty"` PasswordHash string `json:"-"` }
User represents a user User is identified by email and authenticated by JWT. Password is hidden by custom marshaller.
Click to show internal directories.
Click to hide internal directories.