app

package
v0.0.0-...-db58b17 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuth

func CheckAuth(req *http.Request) bool

func CheckTopic

func CheckTopic(topic string) bool

func NewKafka

func NewKafka() http.Handler

Types

type App

type App struct {
	S      *negroni.Negroni
	Router http.Handler
	Conf   *Http2MQ
}

func NewApp

func NewApp(f string) (*App, error)

func (*App) Close

func (a *App) Close()

func (*App) Run

func (a *App) Run()

type AuthUser

type AuthUser struct {
	Name     string
	Password string
}

type Http2MQ

type Http2MQ struct {
	WebConf   `yaml:"web"`
	KafkaConf `yaml:"kafka"`
	UserConf  []string            `yaml:"users"`
	User      map[string]AuthUser `yaml:"-"`
	Topics    []string            `yaml:"topics"`
	TopicMap  map[string]bool     `yaml:"-"`
}
var Conf *Http2MQ

func InitConf

func InitConf(file string) (*Http2MQ, error)

type Kafka

type Kafka struct {
	Topic string
}

func (*Kafka) DoGet

func (k *Kafka) DoGet(res http.ResponseWriter, req *http.Request)

func (*Kafka) DoPost

func (k *Kafka) DoPost(res http.ResponseWriter, req *http.Request)

func (*Kafka) ServeHTTP

func (k *Kafka) ServeHTTP(w http.ResponseWriter, r *http.Request)

type KafkaConf

type KafkaConf struct {
	Brokers      string `yaml:"brokers"`
	Topic        string `yaml:"topic"`
	ConsumerUser string `yaml:"consumer_user"`
	ZK           string `yaml:"zk"`
	ZkRoot       string `yaml:"zk_root"`

	ZKServers     []string             `yaml:"-"`
	SyncProducer  sarama.SyncProducer  `yaml:"-"`
	AsyncProducer sarama.AsyncProducer `yaml:"-"`
	Consumer      sarama.Consumer      `yaml:"-"`
}

type Logger

type Logger struct {
	// Logger inherits from log.Logger used to log messages with the Logger middleware
	*log.Logger
}

func NewLogger

func NewLogger() *Logger

NewLogger returns a new Logger instance

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type WebConf

type WebConf struct {
	AccessLog string `yaml:"access_log"`
	ErrorLog  string `yaml:"error_log"`
	Port      int    `yaml:"port"`
}

Jump to

Keyboard shortcuts

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