Skip to content
This repository was archived by the owner on Mar 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
redis-docker:
docker-redis:
# * Pull the latest Redis official image.
docker pull redis:latest
# * Launch the Redis container.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
```plaintext
http://localhost:3000
/ready
/redis
/redis/ready
/sqlite/ready
```


Expand Down
Empty file added database/database.sql
Empty file.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ require github.com/redis/go-redis/v9 v9.11.0
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/mattn/go-sqlite3 v1.14.32 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/redis/go-redis/v9 v9.11.0 h1:E3S08Gl/nJNn5vkxd2i78wZxWAPNZgUNTp8WIJUAiIs=
github.com/redis/go-redis/v9 v9.11.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
8 changes: 4 additions & 4 deletions src/handlers/redis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package handlers

import (
services "GoRedis/src/services/redis_service"
"GoRedis/src/services"
"GoRedis/src/utils"
"context"
"encoding/json"
Expand All @@ -11,13 +11,13 @@ import (
"strconv"
)

func RedisHandler(w http.ResponseWriter, r *http.Request) {
func RedisReadyHandler(w http.ResponseWriter, r *http.Request) {
ctx := context.Background()
redisClient := services.NewRedisClient()
_, err := redisClient.Ping(ctx).Result()

if err != nil {
log.Print(utils.TextRed("/redis " + strconv.Itoa(500)))
log.Print(utils.TextRed("/redis/ready " + strconv.Itoa(500)))
errorResponse := &utils.HTTPResponse{Message: "Failed redis connection.", Status: 500}
errorResponseJson, _ := json.Marshal(errorResponse)
fmt.Fprint(w, string(errorResponseJson))
Expand All @@ -26,6 +26,6 @@ func RedisHandler(w http.ResponseWriter, r *http.Request) {

response := &utils.HTTPResponse{Message: "Redis is ready.", Status: 200}
responseJson, _ := json.Marshal(response)
log.Print(utils.TextGreen("/redis " + strconv.Itoa(response.Status)))
log.Print(utils.TextGreen("/redis/ready " + strconv.Itoa(response.Status)))
fmt.Fprint(w, string(responseJson))
}
17 changes: 17 additions & 0 deletions src/handlers/sqlite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package handlers

import (
"GoRedis/src/utils"
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
)

func SQLiteReadyHandler(w http.ResponseWriter, r *http.Request) {
response := &utils.HTTPResponse{Message: "SQLite is ready", Status: 200}
responseJson, _ := json.Marshal(response)
log.Print(utils.TextGreen("/sqlite/ready " + strconv.Itoa(response.Status)))
fmt.Fprint(w, string(responseJson))
}
5 changes: 3 additions & 2 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func main() {
log.Print(utils.TextGreen("Server live at port http://localhost:" + port))

// * These are all the server routes.
http.HandleFunc("/", handlers.ReadyHandler)
http.HandleFunc("/redis", handlers.RedisHandler)
http.HandleFunc("/ready", handlers.ReadyHandler)
http.HandleFunc("/redis/ready", handlers.RedisReadyHandler)
http.HandleFunc("/sqlite/ready", handlers.SQLiteReadyHandler)

// * You can setup the server here.
s := &http.Server{
Expand Down
3 changes: 0 additions & 3 deletions src/services/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package services

import "github.com/redis/go-redis/v9"

type RedisPayload struct {
Id string
Description string
}

func NewRedisClient() *redis.Client {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Expand Down
6 changes: 0 additions & 6 deletions src/services/redis_service/payload.go

This file was deleted.

1 change: 1 addition & 0 deletions src/services/sqlite_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package services
22 changes: 22 additions & 0 deletions vendor/github.com/cespare/xxhash/v2/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions vendor/github.com/cespare/xxhash/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/cespare/xxhash/v2/testall.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading