Skip to content

Commit

Permalink
More document.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngdinhtoan committed Jul 2, 2015
1 parent 2171f62 commit 1490919
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 0 additions & 5 deletions jira/config.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ jira:
auth:
login: username
password: password
priority_color:
P0: danger
P1: danger
P2: warning
P3: good
9 changes: 9 additions & 0 deletions jira/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Package jira implement slackcmd.Commander to handle request about jira ticket,
// it will get ticket IDs from request, and give back ticket details into the channel that sent command.
//
// This package (slackcmd also) use Viper (https://github.com/spf13/viper) for manage configuration of app,
// so, copy config from file `config.yml.dist` to your application config, replace by your config value,
// and use Viper to load the config.
//
// Check out example package in (github.com/ngdinhtoan/slackcmd/example) to see how to use this package.
package jira
8 changes: 5 additions & 3 deletions payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ func newPayloadByForm(form url.Values) *Payload {

// PayloadValidator define interface which will be used to verify payload
type PayloadValidator interface {
// Validate will check if given token (sent by Slack) is same as registered token for command
// Validate payload return nil if payload is valid, otherwise return an error
Validate(payload *Payload) error
}

// NewTokenValidator return an implement of PayloadValidator,
// token validator will check if token sent by Slack Commands
// are match with token that in configuration
// TokenValidator will check if token sent by Slack Commands are match with token that in configuration.
// Token in configuration will be load by Viper (github.com/spf13/viper) at key `slackcmd.tokens`,
// that key should be a map of comand and token, check `config.yml.dist` in package example.
// If token was not configured, then the payload is always valid with any token.
func NewTokenValidator() PayloadValidator {
return &tokenValidator{}
}
Expand Down

0 comments on commit 1490919

Please sign in to comment.