You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-5Lines changed: 44 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@
5
5
6
6
A minimal HTTP server implemented using Go’s net/http package. Implemented to understand how handlers, middleware, concurrency, and context propagation work in Go.
7
7
8
-
## Features (in the current stage)
8
+
## Features
9
9
### Endpoints:
10
-
-**`/`**: endpoint that is protected by an authentication middleware. It performs no task other than printing a message.
10
+
-**`/health`**: Returns OK if server is running.
11
11
12
12
-**`/stats`**: endpoint that returns the request metrics like total requests, successful requests and Unauthorized requests in JSON.
13
13
@@ -16,8 +16,10 @@ For example `http://localhost:4000/work?limit=1000` will compute the first 1000
16
16
17
17
-**`/upload`**: Recieves the file in the POST request form field. Creates a temporary file with a unique name in the `./uploads` directory using `os.CreateTemp` and copies the file to it using `io.Copy()`. Renames the temp file using os.Rename() with a safe name created by a helper method in the format `./uploads/uuid_originalFileName.extension`. `uuid` is a unique ID generated by `google/uuid` to maintain unique file names. Performs clean up when the function returns.
18
18
19
+
-**`/download`**: Recieves the file name from the incoming request's `file` query. Checks if the file exists, using `os.Stat()`. If the file exists, it uses `http.ServeFile()` to send the file the client.
20
+
19
21
### Middlewares:
20
-
-**`AuthMiddleware()`**: protects the endpoints and returns 401 if the Basic Auth credentials are invalid.
22
+
-**`AuthMiddleware()`**: protects the endpoints and returns 401 if the Basic Auth credentials are invalid. The password has been hardcoded because this is just a practice/learning project and I wanted to focus on other important concepts such as file uploading and downloading.
21
23
22
24
-**`LoggingMiddleware()`**: logs the request's method, path, timestamp and time taken to complete the request.
23
25
@@ -42,5 +44,42 @@ For example `http://localhost:4000/work?limit=1000` will compute the first 1000
42
44
43
45
---
44
46
45
-
> # Important Note !
46
-
> **This project is still under development. The README will be updated with new features and endpoints in the coming days.**
0 commit comments