<commit_before>package mmic

import (
	log "github.com/Sirupsen/logrus"

	"fmt"
	"github.com/eternnoir/mmic/mmic/config"
	"github.com/eternnoir/mmic/mmic/handlers"
	"github.com/eternnoir/mmic/mmic/handlers/trello"
	"github.com/labstack/echo"
	"github.com/labstack/echo/engine/standard"
	"github.com/labstack/echo/middleware"
)

type Mmic struct {
	Port       string
	HttpServer *echo.Echo
	RouteMap   map[string]handlers.Handler
}

func NewMmic(config *config.MmicConfig) (*Mmic, error) {
	log.Infof("Create Mnic by mmic config: %#v", config)
	mmic := &Mmic{Port: config.Port, HttpServer: echo.New()}
	mmic.RouteMap = make(map[string]handlers.Handler)
	err := mmic.bindHandlers(config)
	if err != nil {
		return nil, err
	}

	return mmic, nil
}

func (mmic *Mmic) bindHandlers(config *config.MmicConfig) error {
	err := mmic.bindTrelloHandlers(config.TrelloConfigs)
	if err != nil {
		log.Errorf("Bind handler fail. %s", err)
		return err
	}

	return nil
}

func (mmic *Mmic) bindTrelloHandlers(configs []config.TrelloConfig) error {
	for _, config := range configs {
		if _, inmap := mmic.RouteMap[config.RoutePath]; inmap {
			return fmt.Errorf("Rout path %s already exist.", config.RoutePath)
		}
		th := trello.NewTrelloHandler(config)
		log.Debugf("Bind %#v", config)
		mmic.HttpServer.Post(config.RoutePath, th)
		mmic.RouteMap[config.RoutePath] = th
	}
	return nil
}

func (mmic *Mmic) Start() {
	mmic.HttpServer.Use(middleware.Logger())
	mmic.HttpServer.Use(middleware.Recover())
	mmic.HttpServer.Run(standard.New(":" + mmic.Port))
}<commit_msg>Add empty handler.<commit_after>package mmic

import (
	log "github.com/Sirupsen/logrus"

	"fmt"
	"github.com/eternnoir/mmic/mmic/config"
	"github.com/eternnoir/mmic/mmic/handlers"
	"github.com/eternnoir/mmic/mmic/handlers/trello"
	"github.com/labstack/echo"
	"github.com/labstack/echo/engine/standard"
	"github.com/labstack/echo/middleware"
	"net/http"
)

type Mmic struct {
	Port       string
	HttpServer *echo.Echo
	RouteMap   map[string]handlers.Handler
}

func NewMmic(config *config.MmicConfig) (*Mmic, error) {
	log.Infof("Create Mnic by mmic config: %#v", config)
	mmic := &Mmic{Port: config.Port, HttpServer: echo.New()}
	mmic.RouteMap = make(map[string]handlers.Handler)
	err := mmic.bindHandlers(config)
	if err != nil {
		return nil, err
	}

	return mmic, nil
}

func (mmic *Mmic) bindHandlers(config *config.MmicConfig) error {
	err := mmic.bindTrelloHandlers(config.TrelloConfigs)
	if err != nil {
		log.Errorf("Bind handler fail. %s", err)
		return err
	}

	return nil
}

func (mmic *Mmic) bindTrelloHandlers(configs []config.TrelloConfig) error {
	for _, config := range configs {
		if _, inmap := mmic.RouteMap[config.RoutePath]; inmap {
			return fmt.Errorf("Rout path %s already exist.", config.RoutePath)
		}
		th := trello.NewTrelloHandler(config)
		log.Debugf("Bind %#v", config)
		mmic.HttpServer.Post(config.RoutePath, th)
		mmic.HttpServer.Head(config.RoutePath, emptyHandler())
		mmic.RouteMap[config.RoutePath] = th
	}
	return nil
}

func (mmic *Mmic) Start() {
	mmic.HttpServer.Use(middleware.Logger())
	mmic.HttpServer.Use(middleware.Recover())
	mmic.HttpServer.Run(standard.New(":" + mmic.Port))
}

func emptyHandler() echo.HandlerFunc {
	return func(c echo.Context) error {
		return c.String(http.StatusOK, "Hi")
	}
}
{'fraction_non_alphanumeric': 0.14571342017570432, 'fraction_numerical': 0.0, 'mean_word_length': 4.587140439932318, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7004140', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1277, 'n_words': 237}