Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: Refactor site to improve testing#2014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 1 commit intomainfromrefactorsite
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioncoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -334,7 +334,7 @@ func New(options *Options) *API {
r.Get("/state", api.workspaceBuildState)
})
})
r.NotFound(site.DefaultHandler().ServeHTTP)
r.NotFound(site.Handler(site.FS()).ServeHTTP)

return api
}
Expand Down
12 changes: 0 additions & 12 deletionssite/embed_slim.go
View file
Open in desktop

This file was deleted.

24 changes: 0 additions & 24 deletionssite/embed.go → site/site.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
//go:build embed
// +build embed

package site

import (
"bytes"
"embed"
"fmt"
"io"
"io/fs"
Expand All@@ -21,26 +17,6 @@ import (
"golang.org/x/xerrors"
)

// The `embed` package ignores recursively including directories
// that prefix with `_`. Wildcarding nested is janky, but seems to
// work quite well for edge-cases.
//go:embed out
//go:embed out/bin/*
var site embed.FS

func DefaultHandler() http.Handler {
// the out directory is where webpack builds are created. It is in the same
// directory as this file (package site).
siteFS, err := fs.Sub(site, "out")

if err != nil {
// This can't happen... Go would throw a compilation error.
panic(err)
}

return Handler(siteFS)
}

// Handler returns an HTTP handler for serving the static site.
func Handler(fileSystem fs.FS) http.Handler {
// html files are handled by a text/template. Non-html files
Expand Down
24 changes: 24 additions & 0 deletionssite/site_embed.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
//go:build embed
// +build embed

package site

import (
"embed"
"io/fs"
)

//go:embed out
//go:embed out/bin/*
var site embed.FS

func FS() fs.FS {
// the out directory is where webpack builds are created. It is in the same
// directory as this file (package site).
out, err := fs.Sub(site, "out")
if err != nil {
// This can't happen... Go would throw a compilation error.
panic(err)
}
return out
}
15 changes: 15 additions & 0 deletionssite/site_slim.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
//go:build !embed
// +build !embed

package site

import (
"embed"
"io/fs"
)

var slim embed.FS

func FS() fs.FS {
return slim
}
3 changes: 0 additions & 3 deletionssite/embed_test.go → site/site_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
//go:build embed
// +build embed

package site_test

import (
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp