<commit_before>package sisito

import (
	"gopkg.in/gin-gonic/gin.v1"
)

type Server struct {
	Engine *gin.Engine
	Router gin.IRouter
	Driver *Driver
}

func NewServer(config *Config, driver *Driver) (server *Server) {
	engine := gin.Default()

	server = &Server{
		Engine: engine,
		Router: engine,
		Driver: driver,
	}

	if len(config.User) > 0 {
		accounts := gin.Accounts{}

		for _, u := range config.User {
			accounts[u.Userid] = u.Password
		}

		server.Router = engine.Group("", gin.BasicAuth(accounts))
	}

	return
}

func (server *Server) ping(c *gin.Context) {
	c.JSON(200, gin.H{
		"message": "pong",
	})
}

func (server *Server) bounced(c *gin.Context) {
	recipient := c.Query("recipient")
	digest := c.Query("digest")
	senderdomain := c.Query("senderdomain")

	if recipient == "" && digest == "" {
		c.JSON(400, gin.H{
			"message": `"recipient" or "digest" is not present`,
		})
	} else if recipient == "" && digest == "" {
		c.JSON(400, gin.H{
			"message": `"recipient" or "digest" is not present`,
		})
	} else {
		var name string
		var value string

		if recipient != "" && digest == "" {
			name = "recipient"
			value = recipient
		} else if recipient == "" || digest != "" {
			name = "digest"
			value = digest
		}

		bounced, err := server.Driver.IsBounced(name, value, senderdomain)

		if err != nil {
			panic(err)
		}

		c.JSON(200, gin.H{
			"bounced": bounced,
		})
	}
}

func (server *Server) Run() {
	engine := server.Engine
	//router := server.Router

	engine.GET("/ping", server.ping)
	engine.GET("/bounced", server.bounced)

	engine.Run()
}
<commit_msg>Add basic auth to bounced<commit_after>package sisito

import (
	"gopkg.in/gin-gonic/gin.v1"
)

type Server struct {
	Engine *gin.Engine
	Router gin.IRouter
	Driver *Driver
}

func NewServer(config *Config, driver *Driver) (server *Server) {
	engine := gin.Default()

	server = &Server{
		Engine: engine,
		Router: engine,
		Driver: driver,
	}

	if len(config.User) > 0 {
		accounts := gin.Accounts{}

		for _, u := range config.User {
			accounts[u.Userid] = u.Password
		}

		server.Router = engine.Group("", gin.BasicAuth(accounts))
	}

	return
}

func (server *Server) ping(c *gin.Context) {
	c.JSON(200, gin.H{
		"message": "pong",
	})
}

func (server *Server) bounced(c *gin.Context) {
	recipient := c.Query("recipient")
	digest := c.Query("digest")
	senderdomain := c.Query("senderdomain")

	if recipient == "" && digest == "" {
		c.JSON(400, gin.H{
			"message": `"recipient" or "digest" is not present`,
		})
	} else if recipient == "" && digest == "" {
		c.JSON(400, gin.H{
			"message": `"recipient" or "digest" is not present`,
		})
	} else {
		var name string
		var value string

		if recipient != "" && digest == "" {
			name = "recipient"
			value = recipient
		} else if recipient == "" || digest != "" {
			name = "digest"
			value = digest
		}

		bounced, err := server.Driver.IsBounced(name, value, senderdomain)

		if err != nil {
			panic(err)
		}

		c.JSON(200, gin.H{
			"bounced": bounced,
		})
	}
}

func (server *Server) Run() {
	engine := server.Engine
	router := server.Router

	engine.GET("/ping", server.ping)
	router.GET("/bounced", server.bounced)

	engine.Run()
}

{'fraction_non_alphanumeric': 0.17525125628140703, 'fraction_numerical': 0.008793969849246231, 'mean_word_length': 3.3451568894952253, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 5, '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': '1316835', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1151, 'n_words': 280}