Skip to content

Commit 742222b

Browse files
Modularized the internal structure from technical work standpoint to feature oriented
1 parent af2942c commit 742222b

File tree

11 files changed

+18
-18
lines changed

11 files changed

+18
-18
lines changed

api/middleware/middleware.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55
"time"
66

7-
"github.com/PythonHacker24/linux-acl-management-backend/internal/authentication"
7+
"github.com/PythonHacker24/linux-acl-management-backend/internal/auth"
88
"go.uber.org/zap"
99
)
1010

@@ -36,7 +36,7 @@ func AuthenticationMiddleware(next http.HandlerFunc) http.HandlerFunc {
3636
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3737

3838
/* authenticate the request through JWT */
39-
username, err := authentication.ExtractUsernameFromRequest(r)
39+
username, err := auth.ExtractUsernameFromRequest(r)
4040
if err != nil {
4141
zap.L().Error("Error during authentication",
4242
zap.Error(err),

api/routes/routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"net/http"
55

66
"github.com/PythonHacker24/linux-acl-management-backend/api/middleware"
7-
"github.com/PythonHacker24/linux-acl-management-backend/internal/handlers"
7+
"github.com/PythonHacker24/linux-acl-management-backend/internal/health"
88
)
99

1010
func RegisterRoutes(mux *http.ServeMux) {
1111
mux.Handle("GET /health", http.HandlerFunc(
12-
middleware.LoggingMiddleware(handlers.HealthHandler),
12+
middleware.LoggingMiddleware(health.HealthHandler),
1313
))
1414
}

internal/authentication/authentication.go renamed to internal/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package authentication
1+
package auth
22

33
import (
44
"fmt"

internal/auth/handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package auth

internal/ldap/ldap.go renamed to internal/auth/ldap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ldap
1+
package auth
22

33
import (
44
"os"

internal/models/models.go renamed to internal/auth/model.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
package models
2-
3-
4-
/* health response */
5-
type HealthResponse struct {
6-
Status string `json:"status"`
7-
}
1+
package auth
82

93
/* username and password */
104
type User struct {

internal/auth/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package auth

internal/handlers/handlers.go renamed to internal/health/handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
package handlers
1+
package health
22

33
import (
44
"encoding/json"
55
"net/http"
66

77
"go.uber.org/zap"
88

9-
"github.com/PythonHacker24/linux-acl-management-backend/internal/models"
9+
// "github.com/PythonHacker24/linux-acl-management-backend/internal/models"
1010
)
1111

1212
/* health handler provides status check on the backend server */
1313
func HealthHandler(w http.ResponseWriter, r *http.Request) {
14-
var response models.HealthResponse
14+
var response HealthResponse
1515

1616
w.Header().Set("Content-Type", "application/json")
1717
w.WriteHeader(http.StatusOK)

internal/health/model.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package health
2+
3+
/* health response */
4+
type HealthResponse struct {
5+
Status string `json:"status"`
6+
}

internal/services/services.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)