http

package
v0.0.0-...-4347b6b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest    = errors.New("bad request")
	ErrLimitExceeded = errors.New("limit")
	ErrUnauthorized  = errors.New("unauthorized")
)

Errors used for protocol control flow.

Functions

func Wrap

func Wrap(
	middleware Middleware,
	handler Handler,
) http.HandlerFunc

Wrap takes a Middleware and Handler and returns an http.HandlerFunc.

Types

type Error

type Error struct {
	Err     error
	Message string
}

Error is used to carry additional error informaiton reported back to clients.

func (*Error) Error

func (e *Error) Error() string

type Handler

type Handler func(context.Context, http.ResponseWriter, *http.Request)

Handler is the gateway specific http.HandlerFunc expecting a context.Context.

func AppCreate

func AppCreate(fn core.AppCreateFunc) Handler

AppCreate creates a new App.

func AppList

func AppList(fn core.AppListFunc) Handler

AppList returns all apps.

func AppRetrieve

func AppRetrieve(fn core.AppFetchWithCountsFunc) Handler

AppRetrieve returns the app for the requested id.

func CommentCreate

func CommentCreate(fn core.CommentCreateFunc) Handler

CommentCreate creates a new Comment on behalf of the current user.

func CommentDelete

func CommentDelete(fn core.CommentDeleteFunc) Handler

CommentDelete flags the comment as deleted.

func CommentList

func CommentList(fn core.CommentListFunc) Handler

CommentList returns all comments for the given a Post.

func CommentRetrieve

func CommentRetrieve(fn core.CommentRetrieveFunc) Handler

CommentRetrieve return the comment for the requested id.

func CommentUpdate

func CommentUpdate(fn core.CommentUpdateFunc) Handler

CommentUpdate replaces the value for a comment with the new values.

func ConnectionByState

func ConnectionByState(fn core.ConnectionByStateFunc) Handler

ConnectionByState returns all connections for a user for a certain state.

func ConnectionDelete

func ConnectionDelete(fn core.ConnectionDeleteFunc) Handler

ConnectionDelete flags the given connection as disabled.

func ConnectionFollowers

func ConnectionFollowers(fn core.ConnectionFollowersFunc) Handler

ConnectionFollowers returns the list of users who follow the user with the id.

func ConnectionFollowersMe

func ConnectionFollowersMe(fn core.ConnectionFollowersFunc) Handler

ConnectionFollowersMe returns the list of users who follow the user with the id.

func ConnectionFollowings

func ConnectionFollowings(fn core.ConnectionFollowingsFunc) Handler

ConnectionFollowings returns the list of users the current user is following.

func ConnectionFollowingsMe

func ConnectionFollowingsMe(fn core.ConnectionFollowingsFunc) Handler

ConnectionFollowingsMe returns the list of users the current user is following.

func ConnectionFriends

func ConnectionFriends(fn core.ConnectionFriendsFunc) Handler

ConnectionFriends returns the list of users the current user is friends with.

func ConnectionFriendsMe

func ConnectionFriendsMe(fn core.ConnectionFriendsFunc) Handler

ConnectionFriendsMe returns the list of users the current user is friends with.

func ConnectionSocial

func ConnectionSocial(fn core.ConnectionCreateSocialFunc) Handler

ConnectionSocial takes a list of connection ids and creates connections for the given user.

func ConnectionUpdate

func ConnectionUpdate(fn core.ConnectionUpdateFunc) Handler

ConnectionUpdate stores a new connection or updates the state of an exisitng Connection.

func CounterGetAll

func CounterGetAll(fn core.CounterGetAllFunc) Handler

CounterGetAll returns the sum of all counter for a coutner name.

func CounterSet

func CounterSet(fn core.CounterSetFunc) Handler

CounterSet sets the counter for the current user and the given counter name to the new value.

func DeviceDelete

func DeviceDelete(fn core.DeviceDeleteFunc) Handler

DeviceDelete removes a user's device.

func DeviceUpdate

func DeviceUpdate(fn core.DeviceUpdateFunc) Handler

DeviceUpdate stores the platform and token for a user's device.

func FeedEvents

func FeedEvents(fn core.FeedEventsFunc) Handler

FeedEvents returns the events of the current user driven by the social and interest graph.

func FeedNews

func FeedNews(fn core.FeedNewsFunc) Handler

FeedNews returns the superset aggregration of events and posts driven by the social and interest graph of the current user.

func FeedNotificationsSelf

func FeedNotificationsSelf(fn core.FeedNotificationsSelfFunc) Handler

FeedNotificationsSelf returns the events which target the origin user and their content.

func FeedPosts

func FeedPosts(fn core.FeedPostsFunc) Handler

FeedPosts returns the posts of the current user driven by the social and interest graph.

func Health

func Health(pg *sqlx.DB, rClient *redis.Pool) Handler

Health checks for liveliness of backing servicesa and responds with status.

func InviteCreate

func InviteCreate(fn core.InviteCreateFunc) Handler

InviteCreate stores the key and value for a users invite.

func LikeCreate

func LikeCreate(fn core.LikeCreateFunc) Handler

LikeCreate emits new like event for the post by the current user.

func LikeDelete

func LikeDelete(fn core.LikeDeleteFunc) Handler

LikeDelete removes an existing like event for the currentuser on the post.

func LikesMe

func LikesMe(fn core.LikesUserFunc) Handler

LikesMe returns all Likes for the current user.

func LikesPost

func LikesPost(fn core.LikeListFunc) Handler

LikesPost returns all Likes for a post.

func LikesUser

func LikesUser(fn core.LikesUserFunc) Handler

LikesUser returns all Likes for the given user.

func MemberLogin

func MemberLogin(authConf *oauth2.Config) Handler

MemberLogin authenticates the member via OAuth.

func MemberRetrieveMe

func MemberRetrieveMe(authConf *oauth2.Config) Handler

MemberRetrieveMe returns the current member.

func PlatformCreate

func PlatformCreate(fn core.PlatformCreateFunc) Handler

PlatformCreate stores the provided platform.

func PostCreate

func PostCreate(fn core.PostCreateFunc) Handler

PostCreate creates a new Post.

func PostDelete

func PostDelete(fn core.PostDeleteFunc) Handler

PostDelete flags the Post as deleted.

func PostList

func PostList(fn core.PostListUserFunc) Handler

PostList returns all posts for a user as visible by the current user.

func PostListAll

func PostListAll(fn core.PostListAllFunc) Handler

PostListAll returns all publicly visible posts.

func PostListMe

func PostListMe(fn core.PostListUserFunc) Handler

PostListMe returns all posts of the current user.

func PostRetrieve

func PostRetrieve(fn core.PostRetrieveFunc) Handler

PostRetrieve returns the requested Post.

func PostUpdate

func PostUpdate(fn core.PostUpdateFunc) Handler

PostUpdate reaplces a post with new values.

func ReactionCreate

func ReactionCreate(fn core.ReactionCreateFunc) Handler

ReactionCreate creates a Reaction on the Post.

func ReactionDelete

func ReactionDelete(fn core.ReactionDeleteFunc) Handler

ReactionDelete removes an existing Reaction for the currentUser on the Post.

func ReactionListPost

func ReactionListPost(fn core.ReactionListPostFunc) Handler

ReactionListPost returns all reactions for a Post.

func ReactionListPostByType

func ReactionListPostByType(fn core.ReactionListPostFunc) Handler

ReactionListPostByType returns all reactions for a Post.

func RuleActivate

func RuleActivate(fn core.RuleActivateFunc) Handler

func RuleDeactivate

func RuleDeactivate(fn core.RuleDeactivateFunc) Handler

func RuleDelete

func RuleDelete(fn core.RuleDeleteFunc) Handler

func RuleList

func RuleList(fn core.RuleListFunc) Handler

RuleList returns all rules.

func RuleRetrieve

func RuleRetrieve(fn core.RuleFetchFunc) Handler

RuleRetrieve returns a single rule by id.

func UserCreate

func UserCreate(
	createFn core.UserCreateFunc,
	createWithInviteFn core.UserCreateWithInviteFunc,
) Handler

UserCreate stores the provided user and returns it with a valid session.

func UserDelete

func UserDelete(fn core.UserDeleteFunc) Handler

UserDelete disbales the current user.

func UserFetchConsole

func UserFetchConsole(fn core.UserFetchConsoleFunc) Handler

func UserLogin

func UserLogin(fn core.UserLoginFunc) Handler

UserLogin finds the user by email or username and creates a Session.

func UserLogout

func UserLogout(fn core.UserLogoutFunc) Handler

UserLogout finds the session of the user and destroys it.

func UserRetrieve

func UserRetrieve(fn core.UserRetrieveFunc) Handler

UserRetrieve returns the user for the requested id.

func UserRetrieveMe

func UserRetrieveMe(fn core.UserRetrieveFunc) Handler

UserRetrieveMe returns the current user.

func UserSearch

func UserSearch(fn core.UserSearchFunc) Handler

UserSearch returns all users for the given search query.

func UserSearchConsole

func UserSearchConsole(fn core.UserSearchConsoleFunc) Handler

UserSearchConsole returns users matching the query.

func UserSearchEmails

func UserSearchEmails(fn core.UserListByEmailsFunc) Handler

UserSearchEmails returns all Users for the emails of the payload.

func UserSearchPlatform

func UserSearchPlatform(fn core.UserListByPlatformIDsFunc) Handler

UserSearchPlatform returns all users for the given ids and platform.

func UserUpdate

func UserUpdate(fn core.UserUpdateFunc) Handler

UserUpdate stores the new attributes given.

func UserUpdateConsole

func UserUpdateConsole(fn core.UserUpdateConsoleFunc) Handler

type Middleware

type Middleware func(Handler) Handler

Middleware can be used to chain Handlers with different responsibilities.

func CORS

func CORS() Middleware

CORS adds the standard set of CORS headers.

func Chain

func Chain(ms ...Middleware) Middleware

Chain takes a varidatic number of Middlewares and returns a combined Middleware.

func CtxApp

func CtxApp(apps app.Service) Middleware

CtxApp extracts the App from the Authentication header.

func CtxDeviceID

func CtxDeviceID() Middleware

CtxDeviceID extracts the unique identification for a device.

func CtxPrepare

func CtxPrepare(version string) Middleware

CtxPrepare adds a baseline of information to the Context currently: * api version * route name

func CtxUser

func CtxUser(sessions session.Service, users user.Service) Middleware

CtxUser extracts the user from the Authentication header and adds it to the Context.

func DebugHeaders

func DebugHeaders(rev, host string) Middleware

DebugHeaders adds extra information encoded in a custom header namespace for potential tracing and debugging post-mortem.

func Gzip

func Gzip() Middleware

Gzip ensures proper encoding of the response if the client accepts it.

func HasUserAgent

func HasUserAgent() Middleware

HasUserAgent ensures a valid User-Agent is set.

func Instrument

func Instrument(
	component string,
) Middleware

Instrument observes key aspects of a request/response and exposes Prometheus metrics.

func Log

func Log(logger log.Logger) Middleware

Log logs information per single request-response.

func RateLimit

func RateLimit(limits limiter.Limiter) Middleware

RateLimit enforces request limits per application.

func SecureHeaders

func SecureHeaders() Middleware

SecureHeaders adds a list of commonly recgonised best-pratice security headers. Source: https://www.owasp.org/index.php/List_of_useful_HTTP_headers

func ValidateContent

func ValidateContent() Middleware

ValidateContent checks if content-length and content-type are set for requests with paylaod and adhere to our required limits and values.

Jump to

Keyboard shortcuts

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