Skip to content
Snippets Groups Projects
Verified Commit c2df596f authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Embed default image

parent c07ca9c9
No related branches found
No related tags found
No related merge requests found
Pipeline #20200 passed
......@@ -3,8 +3,7 @@ ADD . ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /piratar
FROM alpine
WORKDIR /app
COPY --from=build-stage /piratar /app
COPY default.jpg /app
WORKDIR /
COPY --from=build-stage /piratar /
EXPOSE 3000
ENTRYPOINT ["/app/piratar"]
ENTRYPOINT ["/piratar"]
3.0.0
3.1.0
default.jpg

106 KiB | W: | H:

default.jpg

51 KiB | W: | H:

default.jpg
default.jpg
default.jpg
default.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -4,11 +4,15 @@ import (
"fmt"
"log"
"path"
"embed"
"strings"
"net/http"
"pirates/piratar/octopus"
)
//go:embed default.jpg
var fs embed.FS
func main() {
http.HandleFunc("/", handler)
......@@ -34,7 +38,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, photo, http.StatusFound)
} else {
fmt.Printf("Piratar for %s not found\n", id)
avatar, _ := fs.ReadFile("default.jpg")
w.Header().Set("Content-Type", "image/jpeg")
http.ServeFile(w, r, "default.jpg")
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(avatar)))
w.Write(avatar)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment