handler

package
v0.0.0-...-36feab7 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler struct {
	core.Handler
	// contains filtered or unexported fields
}

AuthHandler provides functions to handle authentication of the platform, including registrations and logging in.

func NewAuthHandler

func NewAuthHandler(users users.Client, auth auth.Client) *AuthHandler

NewAuthHandler returns a new instance of AuthHandler, taking the following parameters as dependencies.

func (*AuthHandler) Register

func (h *AuthHandler) Register(w http.ResponseWriter, r *http.Request)

Register handles requests to register a user.

func (*AuthHandler) Token

func (h *AuthHandler) Token(w http.ResponseWriter, r *http.Request)

Token is a http.HandlerFunc used to provider an access token for a user, with the credentials given by the TokenRequest body.

type CreatePostRequest

type CreatePostRequest struct {
	Caption string `json:"caption"`
}

CreatePostRequest is the body of the request.

type CreatePostResponse

type CreatePostResponse struct {
	ID string `json:"id"`
}

CreatePostResponse contains the reference id of the newly created post.

type GetProfileResponse

type GetProfileResponse struct {
	users.Profile
	Feed []*posts.FeedItem `json:"feed"`
}

GetProfileResponse returns a user's profile data.

type PostHandler

type PostHandler struct {
	core.Handler
	// contains filtered or unexported fields
}

PostHandler handles requests to the post domain.

func NewPostHandler

func NewPostHandler(client posts.Client, media media.Client) *PostHandler

NewPostHandler returns a new instance of PostHandler.

func (*PostHandler) Create

func (h *PostHandler) Create(w http.ResponseWriter, r *http.Request)

Create handles requests to create a post.

func (*PostHandler) GetFeed

func (h *PostHandler) GetFeed(w http.ResponseWriter, r *http.Request)

GetFeed returns a user's feed.

func (*PostHandler) GetPost

func (h *PostHandler) GetPost(w http.ResponseWriter, r *http.Request)

GetPost returns a post.

func (*PostHandler) Like

func (h *PostHandler) Like(w http.ResponseWriter, r *http.Request)

Like marks a post as liked by the current user.

func (*PostHandler) Unlike

func (h *PostHandler) Unlike(w http.ResponseWriter, r *http.Request)

Unlike marks a post as unliked by the current user.

type RegisterUserResponse

type RegisterUserResponse struct {
	ReferenceID string             `json:"referenceId"`
	Username    string             `json:"username"`
	AccessToken *RegisterUserToken `json:"accessToken"`
}

RegisterUserResponse is the response body of the register request.

type RegisterUserToken

type RegisterUserToken struct {
	Token   string `json:"token"`
	Expires int64  `json:"expires"`
}

RegisterUserToken represents a user's access token in the register user response body.

type TokenRequest

type TokenRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

TokenRequest is a type used to unmarshal a token request's body to.

type UserHandler

type UserHandler struct {
	core.Handler
	// contains filtered or unexported fields
}

UserHandler handles requests to the user domain.

func NewUserHandler

func NewUserHandler(client users.Client, auth auth.Client, posts posts.Client) *UserHandler

NewUserHandler returns a new instance of UserHandler.

func (*UserHandler) Follow

func (h *UserHandler) Follow(w http.ResponseWriter, r *http.Request)

Follow handles requests to make the current user follow the user with the given id.

func (*UserHandler) GetInfo

func (h *UserHandler) GetInfo(w http.ResponseWriter, r *http.Request)

GetInfo handles requests to get information for a user.

func (*UserHandler) GetProfile

func (h *UserHandler) GetProfile(w http.ResponseWriter, r *http.Request)

GetProfile handles requests to get a user's profile.

func (*UserHandler) Unfollow

func (h *UserHandler) Unfollow(w http.ResponseWriter, r *http.Request)

Unfollow handles requests to make the current user unfollow the user with the given id.

Jump to

Keyboard shortcuts

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