http

package
v0.0.0-...-b27e624 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(conf Config) (http.Handler, error)

Types

type Config

type Config struct {
	BaseURL        string
	AllowedOrigins []string
	Guard          Guard
	Logger         logging.Logger
	Rater          Rater
	UserProfiler   UserProfiler
}

func (Config) Validate

func (c Config) Validate() error

type Guard

type Guard interface {
	APIKeyValid(key []byte) (string, error)
}

type JSONString

type JSONString struct {
	IsUpdating bool   `json:"isUpdating,omitempty"`
	NewValue   string `json:"newValue,omitempty"`
}

func (*JSONString) ToStringUpdate

func (i *JSONString) ToStringUpdate() user.StringUpdate

func (*JSONString) UnmarshalJSON

func (i *JSONString) UnmarshalJSON(data []byte) error

type Rater

type Rater interface {
	errors.ToHTTPResponser
	RateUser(token, forUserID, comment string, rating int32) error
	Ratings(token string, filter rating.Filter) ([]rating.Rating, error)
}

type Rating

type Rating struct {
	ID          string `json:"ID,omitempty"`
	ForUserID   string `json:"forUserID,omitempty"`
	ByUserID    string `json:"byUserID,omitempty"`
	Comment     string `json:"comment,omitempty"`
	Rating      int32  `json:"rating,omitempty"`
	Created     string `json:"created,omitempty"`
	LastUpdated string `json:"lastUpdated,omitempty"`
}

*

  • @apiDefine RatingsList200 *
  • @apiSuccess (200 JSON Response) {Object[]} ratings List of ratings (values indented below).
  • @apiSuccess (200 JSON Response) {String} ratings.ID Unique identifier of this rating.
  • @apiSuccess (200 JSON Response) {String} ratings.forUserID Ratee' userID.
  • @apiSuccess (200 JSON Response) {String} ratings.byUserID Rater's userID.
  • @apiSuccess (200 JSON Response) {String} ratings.comment
  • @apiSuccess (200 JSON Response) {Integer{1-5}} ratings.rating Rating awarded by rater to ratee.
  • @apiSuccess (200 JSON Response) {String} ratings.created ISO8601 date of rating creation.
  • @apiSuccess (200 JSON Response) {String} ratings.lastUpdated Last ISO8601 date of update.

func NewRating

func NewRating(r *rating.Rating) *Rating

func NewRatings

func NewRatings(rs []rating.Rating) []Rating

type User

type User struct {
	ID          string  `json:"ID,omitempty"`
	Name        string  `json:"name,omitempty"`
	ICEPhone    string  `json:"ICEPhone,omitempty"`
	Gender      string  `json:"gender,omitempty"`
	AvatarURL   string  `json:"avatarURL,omitempty"`
	Bio         string  `json:"bio,omitempty"`
	Rating      float32 `json:"rating,omitempty"`
	Created     string  `json:"created,omitempty"`
	LastUpdated string  `json:"lastUpdated,omitempty"`
}

*

  • @apiDefine User200 *
  • @apiSuccess (200 JSON Response) {String} ID (publicly accessible) User's ID.
  • @apiSuccess (200 JSON Response) {String} name (publicly accessible) name
  • @apiSuccess (200 JSON Response) {String} ICEPhone User's (In Case of Emergency) phone number.
  • @apiSuccess (200 JSON Response) {String="MALE","FEMALE","OTHER"} gender
  • @apiSuccess (200 JSON Response) {String} avatarURL (publicly accessible) User's profile picture URL.
  • @apiSuccess (200 JSON Response) {String} bio Brief description of user.
  • @apiSuccess (200 JSON Response) {Float{1-5}} rating Overall rating of user.
  • @apiSuccess (200 JSON Response) {String} created ISO8601 date of user profile creation.
  • @apiSuccess (200 JSON Response) {String} lastUpdated last ISO8601 date when this profile was updated.

func NewUser

func NewUser(u *user.User) *User

type UserProfiler

type UserProfiler interface {
	errors.ToHTTPResponser
	Update(token string, update user.UserUpdate) (*user.User, error)
	User(token, ID string, offsetUpdateDate time.Time) (*user.User, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL