-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a03c058
commit 5a1df35
Showing
7 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
resource-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM golang:1.22 AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o /resource-server . | ||
|
||
FROM gcr.io/distroless/static-debian11:nonroot AS runner | ||
|
||
WORKDIR / | ||
|
||
COPY --from=builder --chown=nonroot:nonroot /resource-server /usr/bin/resource-server | ||
|
||
EXPOSE 8080 | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["resource-server", "serve"] | ||
CMD ["resource-server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/baffao/examples/resource-server | ||
|
||
go 1.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
func main() { | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
requestDetails := map[string]string{ | ||
"Method": r.Method, | ||
"Path": r.URL.Path, | ||
} | ||
|
||
authHeader := r.Header.Get("Authorization") | ||
if authHeader != "" { | ||
requestDetails["Authorization"] = authHeader | ||
} | ||
|
||
jsonDetails, err := json.Marshal(requestDetails) | ||
if err != nil { | ||
log.Printf("Error marshaling JSON: %v", err) | ||
return | ||
} | ||
|
||
log.Println(string(jsonDetails)) | ||
}) | ||
|
||
log.Fatal(http.ListenAndServe(":8080", nil)) | ||
} |