summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server.go')
-rw-r--r--server.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/server.go b/server.go
index d610b92..cd2978d 100644
--- a/server.go
+++ b/server.go
@@ -7,6 +7,7 @@ import (
"fmt"
"github.com/justsaumit/go-fic-api/idgen"
+ "github.com/justsaumit/go-fic-api/hasher"
)
type HelloWorld struct {
@@ -19,6 +20,10 @@ func main() {
e.GET("/hello/:name", GreetingsWithParams)
e.GET("/hello-queries", GreetingsWithQuery)
e.GET("/genid", GenerateIDHandler)
+ e.GET("/hasher", hasherHandler)
+ e.GET("/", func(c echo.Context) error {
+ return c.String(http.StatusOK, "Hello, World!")
+ })
e.Logger.Fatal(e.Start(":3000"))
}
@@ -42,7 +47,6 @@ func GreetingsWithQuery(c echo.Context) error {
})
}
-
func GenerateIDHandler(c echo.Context) error {
id := idgen.GenerateID()
//Print the generated ID to the console.
@@ -52,3 +56,12 @@ func GenerateIDHandler(c echo.Context) error {
// Message: "Generated ID: " + id,
//})
}
+
+func hasherHandler(c echo.Context) error {
+ filePath := "./message-orig.txt"
+ hash, err := hasher.CalculateBLAKE2Hash(filePath)
+ if err != nil {
+ return c.String(http.StatusInternalServerError, "Error calculating hash")
+ }
+ return c.String(http.StatusOK, fmt.Sprintf("BLAKE2b hash of %s: %s\n", filePath, hash))
+}