Add production Docker deployment

Amp-Thread-ID: https://ampcode.com/threads/T-01a02485-5574-707c-bff4-5668d83bee8a
Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-08-22 06:54:18 +00:00
co-authored by heaust
parent d95e099fa4
commit eb7508d1c1
11 changed files with 286 additions and 6 deletions
+10
View File
@@ -53,6 +53,7 @@ func newApplication(store *playgroundStore, packages map[string]memoryAsset, mon
func (app *application) routes() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/healthz", app.health)
mux.HandleFunc("/pkg/", app.servePackage)
mux.HandleFunc("/api/playgrounds", app.savePlayground)
mux.HandleFunc("/api/playgrounds/", app.getPlayground)
@@ -66,6 +67,15 @@ func (app *application) routes() http.Handler {
return app.headers(mux)
}
func (app *application) health(response http.ResponseWriter, request *http.Request) {
if request.Method != http.MethodGet && request.Method != http.MethodHead {
response.Header().Set("Allow", "GET, HEAD")
http.Error(response, "method not allowed", http.StatusMethodNotAllowed)
return
}
response.WriteHeader(http.StatusNoContent)
}
func (app *application) headers(next http.Handler) http.Handler {
return http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
response.Header().Set("Cross-Origin-Opener-Policy", "same-origin")