<commit_before>package no.g_v.passwd.resource

import org.springframework.stereotype.Service
import spark.Spark.get
import spark.servlet.SparkApplication

@Service
class RestResources : SparkApplication {

    override fun init() {

        get("/", { request, response ->
            "Spark and Kotlin :-)"
        })
    }
}<commit_msg>Changed the REST end point to return a generated password<commit_after>package no.g_v.passwd.resource

import com.google.gson.Gson
import no.g_v.passwd.domain.*
import no.g_v.passwd.domain.ApgOptionDefaults.*
import no.g_v.passwd.domain.ApgOptions.Companion.valueOrDefault
import no.g_v.passwd.service.PasswordGenerator
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import spark.Spark.get
import spark.servlet.SparkApplication

@Service
class RestResources @Autowired constructor(val passwordGenerator: PasswordGenerator) : SparkApplication {

    override fun init() {

        get("/password", { request, response ->
            val symbolsets = Symbolsets(
                    specialSymbol = SpecialSymbol.mustOrShould(request.queryParams("specialSymbol")),
                    numeralSymbol = NumeralSymbol.mustOrShould(request.queryParams("numeralSymbol")),
                    capitalSymbol = CapitalSymbol.mustOrShould(request.queryParams("capitalSymbol")),
                    smallLetter = SmallLetter.mustOrShould(request.queryParams("smallLetter"))
            )
            val apgOptions = ApgOptions(
                    algorithm = Algorithm.fromText(request.queryParams("algorithm")),
                    numberOfPasswords = valueOrDefault(request.queryParams("numberOfPasswords"), NUMBER_OF_PASSWORDS),
                    minPasswordLength = valueOrDefault(request.queryParams("minLength"), MIN_PASSWORD_LENGTH),
                    maxPasswordLength = valueOrDefault(request.queryParams("maxLength"), MAX_PASSWORD_LENGTH),
                    symbolsets = symbolsets
            )

            response.type("application/json")
            Gson().toJson(passwordGenerator.generate(apgOptions))
        })
    }
}
{'fraction_non_alphanumeric': 0.0947467166979362, 'fraction_numerical': 0.0, 'mean_word_length': 3.166015625, 'pattern_counts': {'":': 0, '<': 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': '2888092', 'n_tokens_mistral': 566, 'n_tokens_neox': 540, 'n_words': 93}