since extension functions aren't allowed on enum e...
# getting-started
j
since extension functions aren't allowed on enum entry names, what is the better approach to implement this?
Copy code
@Suppress("EnumEntryName")
enum class ConfigUri(val raw: String) {

	login("/login"),
	logout("/logout"),
	register("/register"),
	verify("/verify/{hash}"),
	reset1("/reset"),
	reset2("/reset/{hash}")
	;

	fun verify.build(hash: String): String = raw.replace("{hash}", hash)

}
in the endpoints where I declare the GET / POST handlers, I want to be able to do
GET(ConfigUri.login.raw)
and in places where I need to fill in the hashes for example when sending out an email with a verify link, I want to be able to do
ConfigUri.verify.build(hash = generatedRandomHash)
to generate something like
/verify/12344-1324234-sdfsdfs
this is probably equivalent and will actually compile
Copy code
@Suppress("ClassName")
sealed class ConfigUri2(val raw: String) {

	object login : ConfigUri2("/login")
	object verify : ConfigUri2("/verify/{hash}") {
        fun build(hash: String) = raw.replace("{hash}", hash)
    }
	
}
the enums did look a lot cleaner though
b
the enum is the Type, the enum value is instance of that type so you can write extension functions to an actual enum value doesnt make sense, sealed class is how you can solve this of course