Example #1
0
// AddHandlers adds handlers of collaboration
func AddHandlers(m *mux.Mux, mgoCache *cache.MongoCache) {
	httpRateLimiter := helper.NewDefaultRateLimiter()

	cs := &CacheStore{
		MongoCache: mgoCache,
	}

	m.AddHandler(
		handler.Request{
			Handler:   cs.Ping,
			Name:      "collaboration-ping",
			Type:      handler.PostRequest,
			Endpoint:  "/collaboration/ping",
			Ratelimit: httpRateLimiter,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  cs.End,
			Name:     "collaboration-end",
			Type:     handler.PostRequest,
			Endpoint: "/collaboration/end",
		},
	)
}
Example #2
0
func AddHandlers(m *mux.Mux) {
	m.AddHandler(
		handler.Request{
			Handler:  Parse,
			Name:     "mail-parse",
			Type:     handler.PostRequest,
			Endpoint: "/mail/parse",
		},
	)
}
Example #3
0
// AddHandlers added the internal handlers to the given Muxer
func AddHandlers(m *mux.Mux) {
	m.AddHandler(
		handler.Request{
			Handler:  PublishEvent,
			Name:     models.MailPublishEvent,
			Type:     handler.PostRequest,
			Endpoint: "/private/mail/publish",
		},
	)
}
Example #4
0
// AddHandlers added the internal handlers to the given Muxer
func AddHandlers(m *mux.Mux) {
	m.AddHandler(
		handler.Request{
			Handler:  HandleEvent,
			Name:     socialapimodels.DispatcherEvent,
			Type:     handler.PostRequest,
			Endpoint: "/private/dispatcher/{eventName}",
		},
	)
}
Example #5
0
func AddHandlers(m *mux.Mux) {

	m.AddHandler(
		handler.Request{
			Handler:  Location,
			Name:     "client-location",
			Type:     handler.GetRequest,
			Endpoint: "/client/location",
		},
	)
}
Example #6
0
func AddHandlers(m *mux.Mux) {

	// fetch profile feed
	// m.AddHandler("GET", "/account/{id}/profile/feed"
	//   handler.Request{
	//     Handler: account.ListProfileFeed,
	//     Name:    "list-profile-feed",
	//   },
	// )

	m.AddUnscopedHandler(
		handler.Request{
			Handler:  sshkey.Handler,
			Name:     "ssh-key-generator",
			Type:     handler.GetRequest,
			Endpoint: "/sshkey",
		},
	)
}
Example #7
0
func AddHandlers(m *mux.Mux) {

	m.AddHandler(
		handler.Request{
			Handler:  Create,
			Name:     "reply-create",
			Type:     handler.PostRequest,
			Endpoint: "/message/{id}/reply",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  List,
			Name:     "reply-list",
			Type:     handler.GetRequest,
			Endpoint: "/message/{id}/reply",
		},
	)
}
Example #8
0
func AddHandlers(m *mux.Mux) {

	// list messages of the channel
	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  List,
			Name:     "channel-history-list",
			Endpoint: "/channel/{id}/history",
			Type:     handler.GetRequest,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  TempList,
			Name:     "channel-message-history-list",
			Endpoint: "/channel/{id}/list",
			Type:     handler.GetRequest,
		},
	)

	// message count of the channel
	m.AddHandler(
		handler.Request{
			Handler:  Count,
			Name:     "channel-history-count",
			Endpoint: "/channel/{id}/history/count",
			Type:     handler.GetRequest,
		},
	)
}
Example #9
0
func (h *Handler) AddHandlers(m *mux.Mux) {
	// channel subscription
	m.AddHandler(
		handler.Request{
			Handler:  h.SubscribeChannel,
			Name:     "channel-subscribe",
			Type:     handler.PostRequest,
			Endpoint: "/subscribe/channel",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  h.SubscribeNotification,
			Name:     "notification-subscribe",
			Type:     handler.PostRequest,
			Endpoint: "/subscribe/notification",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  h.GetToken,
			Name:     "get-token",
			Type:     handler.PostRequest,
			Endpoint: "/token",
		},
	)
}
Example #10
0
// AddHandlers added the internal handlers to the given Muxer
func AddHandlers(m *mux.Mux) {
	httpRateLimiter := helper.NewDefaultRateLimiter()

	m.AddHandler(
		handler.Request{
			Handler:   Ping,
			Name:      "presence-ping",
			Type:      handler.GetRequest,
			Endpoint:  presence.EndpointPresencePing,
			Ratelimit: httpRateLimiter,
		},
	)
	m.AddHandler(
		handler.Request{
			Handler:   ListMembers,
			Name:      "presence-listmembers",
			Type:      handler.GetRequest,
			Endpoint:  presence.EndpointPresenceListMembers,
			Ratelimit: httpRateLimiter,
		},
	)
	m.AddHandler(
		handler.Request{
			Handler:   HandlePrivatePing,
			Name:      "presence-ping-private",
			Type:      handler.PostRequest,
			Endpoint:  presence.EndpointPresencePingPrivate,
			Ratelimit: httpRateLimiter,
		},
	)
}
Example #11
0
// AddHandlers add oauth for koding api
func AddHandlers(m *mux.Mux, config *config.Config) {
	session := modelhelper.Mongo.Session

	oauth := NewOAuthHandler(session)
	m.AddUnscopedHandler(
		handler.Request{
			Handler:  oauth.AuthorizeClient,
			Name:     OauthAuthorization,
			Type:     handler.GetRequest,
			Endpoint: "/oauth/authorize",
		},
	)
	m.AddUnscopedHandler(
		handler.Request{
			Handler:  oauth.GenerateToken,
			Name:     GenerateToken,
			Type:     handler.GetRequest,
			Endpoint: "/oauth/token",
		},
	)

}
Example #12
0
// AddHandlers adds handlers for slack integration
func AddHandlers(m *mux.Mux, l logging.Logger, config *config.Config) {
	manager, err := loadManager(config)
	if err != nil {
		panic(err)
	}

	s := &SneakerS3{
		Manager: manager,
		log:     l,
	}

	m.AddHandler(
		handler.Request{
			Handler:  s.Store,
			Name:     CredentialStore,
			Type:     handler.PostRequest,
			Endpoint: "/credential/{pathName}",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.Get,
			Name:     CredentialGet,
			Type:     handler.GetRequest,
			Endpoint: "/credential/{pathName}",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.Delete,
			Name:     CredentialDelete,
			Type:     handler.DeleteRequest,
			Endpoint: "/credential/{pathName}",
		},
	)

}
Example #13
0
// AddHandlers injects handlers for payment system
func AddHandlers(m *mux.Mux) {
	m.AddHandler(
		handler.Request{
			Handler:  CancelSubscription,
			Name:     "payment-delete-subscription",
			Type:     handler.DeleteRequest,
			Endpoint: EndpointSubscriptionCancel,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  GetSubscription,
			Name:     "payment-get-subscription",
			Type:     handler.GetRequest,
			Endpoint: EndpointSubscriptionGet,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  CreateSubscription,
			Name:     "payment-create-subscription",
			Type:     handler.PostRequest,
			Endpoint: EndpointSubscriptionCreate,
		},
	)

	// Customers

	m.AddHandler(
		handler.Request{
			Handler:  DeleteCustomer,
			Name:     "payment-delete-customer",
			Type:     handler.DeleteRequest,
			Endpoint: EndpointCustomerDelete,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  UpdateCustomer,
			Name:     "payment-update-customer",
			Type:     handler.PostRequest,
			Endpoint: EndpointCustomerUpdate,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  GetCustomer,
			Name:     "payment-get-customer",
			Type:     handler.GetRequest,
			Endpoint: EndpointCustomerGet,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  CreateCustomer,
			Name:     "payment-create-customer",
			Type:     handler.PostRequest,
			Endpoint: EndpointCustomerCreate,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  DeleteCreditCard,
			Name:     "payment-delete-creditcard",
			Type:     handler.DeleteRequest,
			Endpoint: EndpointCreditCardDelete,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  HasCreditCard,
			Name:     "payment-has-creditcard",
			Type:     handler.GetRequest,
			Endpoint: EndpointCreditCardHas,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  AuthCreditCard,
			Name:     "payment-auth-creditcard",
			Type:     handler.PostRequest,
			Endpoint: EndpointCreditCardAuth,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Webhook,
			Name:     "payment-webhoook",
			Type:     handler.PostRequest,
			Endpoint: EndpointWebhook,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  ListInvoice,
			Name:     "payment-list-invoices",
			Type:     handler.GetRequest,
			Endpoint: EndpointInvoiceList,
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Info,
			Name:     "payment-info",
			Type:     handler.GetRequest,
			Endpoint: EndpointInfo,
		},
	)
}
Example #14
0
func AddHandlers(m *mux.Mux) {
	m.AddHandler(
		handler.Request{
			Handler:  Create,
			Name:     "channel-create",
			Type:     handler.PostRequest,
			Endpoint: "/channel",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  List,
			Name:     "channel-list",
			Type:     handler.GetRequest,
			Endpoint: "/channel",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  Search,
			Name:     "channel-search",
			Type:     handler.GetRequest,
			Endpoint: "/channel/search",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  ByName,
			Name:     "channel-get-byname",
			Type:     handler.GetRequest,
			Endpoint: "/channel/name/{name}",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  Get,
			Name:     "channel-get",
			Type:     handler.GetRequest,
			Endpoint: "/channel/{id}",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  CheckParticipation,
			Name:     "channel-check-participation",
			Type:     handler.GetRequest,
			Endpoint: "/channel/checkparticipation",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Delete,
			Name:     "channel-delete",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/delete",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Update,
			Name:     "channel-update",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/update",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  ByParticipants,
			Name:     "channel-by-participants",
			Type:     handler.GetRequest,
			Endpoint: "/channel/by/participants",
		},
	)
}
Example #15
0
func AddHandlers(m *mux.Mux) {

	m.AddHandler(
		handler.Request{
			Handler:  Init,
			Name:     "privatechannel-init",
			Type:     handler.PostRequest,
			Endpoint: "/privatechannel/init",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Send,
			Name:     "privatechannel-send",
			Type:     handler.PostRequest,
			Endpoint: "/privatechannel/send",
		},
	)

	// exempt contents are filtered
	m.AddHandler(
		handler.Request{
			Handler:  List,
			Name:     "privatechannel-list",
			Type:     handler.GetRequest,
			Endpoint: "/privatechannel/list",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Search,
			Name:     "privatechannel-search",
			Type:     handler.GetRequest,
			Endpoint: "/privatechannel/search",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Count,
			Name:     "privatechannel-count",
			Type:     handler.GetRequest,
			Endpoint: "/privatechannel/count",
		},
	)

	/////////////////////////////////////////
	//    These handlers will be merged    //
	/////////////////////////////////////////
	m.AddHandler(
		handler.Request{
			Handler:  Init,
			Name:     "channel-init-with-participants",
			Type:     handler.PostRequest,
			Endpoint: "/channel/initwithparticipants",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Send,
			Name:     "channel-send-with-participants",
			Type:     handler.PostRequest,
			Endpoint: "/channel/sendwithparticipants",
		},
	)

}
Example #16
0
func AddHandlers(m *mux.Mux) {
	// added troll mode protection
	// list channels of the account
	m.AddHandler(
		handler.Request{
			Handler:  ListChannels,
			Name:     "account-channel-list",
			Type:     handler.GetRequest,
			Endpoint: "/account/{id}/channels",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  GetAccountFromSession,
			Name:     "account-info",
			Type:     handler.GetRequest,
			Endpoint: "/account",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  ParticipatedChannelCount,
			Name:     "account-channel-list-count",
			Type:     handler.GetRequest,
			Endpoint: "/account/{id}/channels/count",
		},
	)

	// list posts of the account
	m.AddHandler(
		handler.Request{
			Handler:  ListPosts,
			Name:     "account-post-list",
			Type:     handler.GetRequest,
			Endpoint: "/account/{id}/posts",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  FetchPostCount,
			Name:     "account-post-count",
			Type:     handler.GetRequest,
			Endpoint: "/account/{id}/posts/count",
		},
	)

	// follow the account
	m.AddHandler(
		handler.Request{
			Handler:  Follow,
			Name:     "account-follow",
			Type:     handler.PostRequest,
			Endpoint: "/account/{id}/follow",
		},
	)

	// register an account
	m.AddHandler(
		handler.Request{
			Handler:  Register,
			Name:     "account-create",
			Type:     handler.PostRequest,
			Endpoint: "/account",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Update,
			Name:     "account-update",
			Type:     handler.PostRequest,
			Endpoint: "/account/{id}",
		},
	)

	// un-follow the account
	m.AddHandler(
		handler.Request{
			Handler:  Unfollow,
			Name:     "account-unfollow",
			Type:     handler.PostRequest,
			Endpoint: "/account/{id}/unfollow",
		},
	)

	// check ownership of an object
	m.AddHandler(
		handler.Request{
			Handler:  CheckOwnership,
			Name:     "account-owns",
			Type:     handler.GetRequest,
			Endpoint: "/account/{id}/owns",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  ListGroupChannels,
			Name:     "account-group-channel-list",
			Type:     handler.GetRequest,
			Endpoint: "/account/channels",
		},
	)

}
Example #17
0
func AddHandlers(m *mux.Mux) {

	// exempt contents are filtered
	m.AddHandler(
		handler.Request{
			Handler:  List,
			Name:     "participant-list",
			Type:     handler.GetRequest,
			Endpoint: "/channel/{id}/participants",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  AddMulti,
			Name:     "participant-multi-add",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/participants/add",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  RemoveMulti,
			Name:     "participant-multi-remove",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/participants/remove",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  BlockMulti,
			Name:     "participant-multi-block",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/participants/block",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  UnblockMulti,
			Name:     "participant-multi-unblock",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/participants/unblock",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  UpdatePresence,
			Name:     "participant-presence-update",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/participant/{accountId}/presence",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  AcceptInvite,
			Name:     "participant-invitation-accept",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/invitation/accept",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  RejectInvite,
			Name:     "participant-invitation-reject",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/invitation/reject",
		},
	)
}
Example #18
0
// AddHandlers adds handlers for slack integration
func AddHandlers(m *mux.Mux, config *config.Config) {
	s := &Slack{
		Hostname:          config.Hostname,
		Protocol:          config.Protocol,
		VerificationToken: config.Slack.VerificationToken,
		OAuthConf: &oauth2.Config{
			ClientID:     config.Slack.ClientId,
			ClientSecret: config.Slack.ClientSecret,
			RedirectURL:  config.Slack.RedirectUri,
			Endpoint: oauth2.Endpoint{
				AuthURL:  "https://slack.com/oauth/authorize",
				TokenURL: "https://slack.com/api/oauth.access",
			},
			Scopes: []string{
				// channels.info
				// channels.list
				// Provides us to read public channel list of a team
				"channels:read",

				// chat.postMessage
				// Provides us to write a message to channel as a bot
				"chat:write:bot",

				// groups.info
				// groups.list
				// Provides us to list group channels of user
				"groups:read",

				// im.list
				// Provides us to list im channels of user
				"im:read",

				// mpim.list
				// Provides us to list mpim channels of user
				"mpim:read",

				// team.info
				// Provides us to get team info while creating a team at koding
				"team:read",

				// users.getPresence
				// users.info
				// Provides us the presence information which we use to list
				// online users at the top of the users list
				"users:read",

				// usergroups.list
				// usergroups.users.list
				// Provides us the list usergroups of user
				"usergroups:read",

				// includes bot user functionality. Unlike incoming-webhook and
				// commands, the bot scope grants your bot user access to a
				// subset of Web API methods.
				//
				// https://api.slack.com/bot-users#bot-methods
				// Provides us the bot functionality. Even tho bot has most of
				// the above scopes, slack's api is not consistent and sometimes
				// they send the response, sometimes they fail with missing
				// scope error
				"bot",
			},
		},
	}

	m.AddHandler(
		handler.Request{
			Handler:  s.Send,
			Name:     models.SlackOauthSend,
			Type:     handler.GetRequest,
			Endpoint: "/slack/oauth",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.Callback,
			Name:     models.SlackOauthCallback,
			Type:     handler.GetRequest,
			Endpoint: "/slack/oauth/callback",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.Success,
			Name:     models.SlackOauthSuccess,
			Type:     handler.GetRequest,
			Endpoint: "/slack/oauth/success",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.ListUsers,
			Name:     models.SlackListUsers,
			Type:     handler.GetRequest,
			Endpoint: "/slack/users",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.ListChannels,
			Name:     models.SlackListChannels,
			Type:     handler.GetRequest,
			Endpoint: "/slack/channels",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.TeamInfo,
			Name:     models.SlackTeamInfo,
			Type:     handler.GetRequest,
			Endpoint: "/slack/team",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  s.PostMessage,
			Name:     models.SlackPostMessage,
			Type:     handler.PostRequest,
			Endpoint: "/slack/message",
		},
	)

	m.AddUnscopedHandler(
		handler.Request{
			Handler:  s.SlashCommand,
			Name:     models.SlackSlashCommand,
			Type:     handler.PostRequest,
			Endpoint: "/slack/slash",
		},
	)
}
Example #19
0
func AddHandlers(m *mux.Mux) {

	// add a new messages to the channel
	m.AddHandler(
		handler.Request{
			Handler:  Create,
			Name:     "channel-message-create",
			Type:     handler.PostRequest,
			Endpoint: "/channel/{id}/message",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Delete,
			Name:     models.REQUEST_NAME_MESSAGE_DELETE,
			Type:     handler.DeleteRequest,
			Endpoint: "/message/{id}",
		},
	)

	m.AddHandler(
		handler.Request{
			Handler:  Update,
			Name:     models.REQUEST_NAME_MESSAGE_UPDATE,
			Type:     handler.PostRequest,
			Endpoint: "/message/{id}",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  Get,
			Name:     models.REQUEST_NAME_MESSAGE_GET,
			Type:     handler.GetRequest,
			Endpoint: "/message/{id}",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  GetWithRelated,
			Name:     "message-get-with-related",
			Type:     handler.GetRequest,
			Endpoint: "/message/{id}/related",
		},
	)

	// exempt contents are filtered
	// caching enabled
	m.AddHandler(
		handler.Request{
			Handler:  GetBySlug,
			Name:     "message-get-by-slug",
			Type:     handler.GetRequest,
			Endpoint: "/message/slug/{slug}",
		},
	)
}