// greeting salutes the user.
552066
func greeting(p messenger.Profile, r *messenger.Response) error {
	return r.Text(fmt.Sprintf("Hello, %v!", p.FirstName), messenger.ResponseType)
}
948516
func init() {
	// Anything unrecognized gets redirected to the status page.
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, "/debug/status", http.StatusFound)
	})
}
203806
func (h *getHello) Handle(params GetHelloParams) middleware.Responder {
	log.Debug("Handling request for /hello")
	return NewGetHelloOK()
}
209507
func (eh userSettingsUpdateEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*UserSettingsUpdate); ok {
		eh(s, t)
	}
}
1324501
func HelloHandler(version uint8, h of.Handler) of.Handler {
	fn := func(rw of.ResponseWriter, r *of.Request) {
		// Copy the header of retrieved message,
		// including the trasnaction identifier.
		header := r.Header.Copy()
		header.Version = version

		// Send a response to the called with a version
		// supported version in the header.
		rw.Write(header, nil)

		if h != nil {
			h.Serve(rw, r)
		}
	}

	return of.HandlerFunc(fn)
}
153057
func Greeting(r *rand.Rand, name string) string {
	var n int
	if len(name) == 0 {
		n = r.Intn(3)
		switch n {
		case 0:
			return fmt.Sprintf("Hi, %s.", name)
		case 1:
			return fmt.Sprintf("Hello, %s.", name)
		case 2:
			return fmt.Sprintf("Hi there, %s.", name)
		}
	} else {
		n = r.Intn(3)
		switch n {
		case 0:
			return "Hi. How can I help you?"
		case 1:
			return "Hello. What can I do for you?"
		}
	}
	log.Debug("greeting failed to return a response")
	return ""
}
1285610
func (c *Client) UseResponse(fn context.HandlerFunc) *Client {
	c.Middleware.UseResponse(fn)
	return c
}
1188407
func (eh presenceUpdateEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*PresenceUpdate); ok {
		eh(s, t)
	}
}
1048061
func (c *Context) User() string {
	if ae != nil {
		return ae.User(c.ae)
	}
	return os.Getenv("USER")
}
715773
func (u *UserService) Login(name, passw string) (*loginResponse, error) {

	derived := pbkdf2.Key([]byte(passw), []byte(reverse(passw)), 1000, 16, sha1.New)

	reqParams := url.Values{
		"auth": []string{name},
		"pass": []string{fmt.Sprintf("%x", derived)},
	}

	oldHost := u.c.api.Api.BaseUrl.Host
	u.c.api.Api.BaseUrl.Host = strings.Replace(oldHost, "api.oboom.com", "www.oboom.com", 1)

	res := u.c.api.Res("login")
	res.Headers.Set("Content-Type", "application/x-www-form-urlencoded")
	res.Payload = strings.NewReader(reqParams.Encode())
	resp, err := res.FormPost(nil)
	arr, err := processResponse(resp, err)
	if err != nil {
		return nil, err
	}

	u.c.api.Api.BaseUrl.Host = oldHost

	var liResp loginResponse
	if err = decodeInto(&liResp, arr[1]); err != nil {
		return nil, err
	}

	u.session = liResp.Session

	return &liResp, nil
}
763375
func NewGreeterAPI(spec *loads.Document) *GreeterAPI {
	return &GreeterAPI{
		handlers:            make(map[string]map[string]http.Handler),
		formats:             strfmt.Default,
		defaultConsumes:     "application/json",
		defaultProduces:     "application/json",
		customConsumers:     make(map[string]runtime.Consumer),
		customProducers:     make(map[string]runtime.Producer),
		ServerShutdown:      func() {},
		spec:                spec,
		ServeError:          errors.ServeError,
		BasicAuthenticator:  security.BasicAuth,
		APIKeyAuthenticator: security.APIKeyAuth,
		BearerAuthenticator: security.BearerAuth,
		JSONConsumer:        runtime.JSONConsumer(),
		TxtProducer:         runtime.TextProducer(),
		GetGreetingHandler: GetGreetingHandlerFunc(func(params GetGreetingParams) middleware.Responder {
			return middleware.NotImplemented("operation GetGreeting has not yet been implemented")
		}),
	}
}
152021
func Whoami() error {
	c, err := client.New()

	if err != nil {
		return err
	}

	fmt.Printf("You are %s at %s\n", c.Username, c.ControllerURL.String())
	return nil
}
968553
func (c *RedisClient) Hello() (HelloResponse, error) {

	vals, err := redis.Values(c.conn.Do("HELLO"))
	ret := HelloResponse{}
	if err != nil {
		return ret, err
	}

	if len(vals) < 3 {
		return ret, fmt.Errorf("disque: invalid HELLO response: %v", vals)
	}

	versionId := vals[0].(int64)
	if versionId != HelloVersionId {
		return ret, fmt.Errorf("disque: unsupported HELLo version: %d, expected %d", versionId, HelloVersionId)
	}

	ret.NodeId = string(vals[1].([]byte))
	ret.Nodes = make(nodeList, 0, len(vals)-2)
	for _, v := range vals {

		if arr, ok := v.([]interface{}); ok {
			if len(arr) != 4 {
				log.Println("Invalid HELLO entry: %v", arr)
				continue
			}

			prio, err := strconv.ParseInt(string(arr[3].([]byte)), 10, 32)
			if err != nil {
				log.Println("Invalid priority: %v", arr[3])
				continue
			}

			addr := ""
			host := string(arr[1].([]byte))

			//in a single node, it doesn't know its IP, we just take it from the client itself
			if host == "" {
				addr = c.node.Addr
			} else {
				addr = fmt.Sprintf("%s:%s", host, string(arr[2].([]byte)))
			}

			add, err := net.ResolveTCPAddr("tcp", addr)
			if err != nil {
				log.Printf("Invalid address given: %s", addr)
				continue
			}
			node := Node{
				Id:       string(arr[0].([]byte)),
				Addr:     add.String(),
				Priority: int(prio),
			}

			ret.Nodes = append(ret.Nodes, node)
		}

	}

	return ret, nil
}
78678
func (c *Confirm) Prompt() (interface{}, error) {
	// render the question template
	err := c.Render(
		ConfirmQuestionTemplate,
		ConfirmTemplateData{Confirm: *c},
	)
	if err != nil {
		return "", err
	}

	// get input and return
	return c.getBool(false)
}
287104
func (o *GreeterAPI) Context() *middleware.Context {
	if o.context == nil {
		o.context = middleware.NewRoutableContext(o.spec, o, nil)
	}

	return o.context
}
1036767
func main() {
	app := gear.New()

	// Add logging middleware
	app.UseHandler(logging.Default(true))

	// Add router middleware
	router := gear.NewRouter()

	// try: http://127.0.0.1:3000/hello
	router.Get("/hello", func(ctx *gear.Context) error {
		return ctx.HTML(200, "<h1>Hello, Gear!</h1>")
	})

	// try: http://127.0.0.1:3000/test?query=hello
	router.Otherwise(func(ctx *gear.Context) error {
		return ctx.JSON(200, map[string]interface{}{
			"Host":    ctx.Host,
			"Method":  ctx.Method,
			"Path":    ctx.Path,
			"URL":     ctx.Req.URL.String(),
			"Headers": ctx.Req.Header,
		})
	})
	app.UseHandler(router)
	app.Error(app.Listen(":3000"))
}
98066
func (auth *PlainAuth) Response() string {
	return fmt.Sprintf("\000%s\000%s", auth.Username, auth.Password)
}