Skip to content

feat: nextrouter pkg to handle nextjs routing rules #167

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Feb 9, 2022
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dd6d315
Add in-memory fs example
bryphe-coder Feb 5, 2022
33897e5
Integrate test server too
bryphe-coder Feb 5, 2022
b8d092c
Some initial test cases for files at root
bryphe-coder Feb 5, 2022
9949261
Serve contents from filesystem
bryphe-coder Feb 5, 2022
fadc0b6
Factor router out
bryphe-coder Feb 5, 2022
771f39d
Add recursive router building
bryphe-coder Feb 5, 2022
78406b1
Hook up recursive case
bryphe-coder Feb 5, 2022
50c72ba
Refactor to handle different file-serving cases
bryphe-coder Feb 5, 2022
7a98a48
Handle case w/o html extension
bryphe-coder Feb 5, 2022
1eb2402
Handle redirecting to index.html at root
bryphe-coder Feb 5, 2022
b0fd9a8
Add test case for nested path
bryphe-coder Feb 5, 2022
a506148
Remove now-unnecessary smoke test
bryphe-coder Feb 5, 2022
b59e2a8
Some clean up
bryphe-coder Feb 5, 2022
ff75695
Refactor to use http.ServeContent
bryphe-coder Feb 5, 2022
a410396
Simplify router construction
bryphe-coder Feb 5, 2022
15c38b9
rtr -> router
bryphe-coder Feb 5, 2022
c813b5e
Handle serving non-html files
bryphe-coder Feb 5, 2022
317c040
Handle trailing-slash case
bryphe-coder Feb 5, 2022
133e452
Implement dynamic routing
bryphe-coder Feb 5, 2022
6d8f412
Add test case to verify static paths are preferred over dynamic paths
bryphe-coder Feb 5, 2022
a3ecd7f
Handle dynamic routing for folders
bryphe-coder Feb 5, 2022
700c9ef
Handle catch-all routes
bryphe-coder Feb 5, 2022
05a369e
Start plumbing in a way to inject template parameters
bryphe-coder Feb 5, 2022
03a20c1
Start adding plumbing for templates
bryphe-coder Feb 5, 2022
199d468
Add template functionality
bryphe-coder Feb 5, 2022
ca515e4
Set up 404 handling
bryphe-coder Feb 5, 2022
6072bad
Use nextrouter package in site, which simplifies it quite a bit
bryphe-coder Feb 5, 2022
826eaf5
Update interface to take logger
bryphe-coder Feb 5, 2022
dac34f5
Additional comments
bryphe-coder Feb 5, 2022
92d4eb0
Fix embed_test
bryphe-coder Feb 5, 2022
5262b7f
Remove now-unused noop template func
bryphe-coder Feb 5, 2022
33342e5
Merge main
bryphe-coder Feb 8, 2022
750bec9
Switch route addition from info -> debug log level
bryphe-coder Feb 8, 2022
c15b046
Invert logic to remove layer of indentation
bryphe-coder Feb 8, 2022
c17fc15
Rename buildRoutes -> registerRoutes
bryphe-coder Feb 8, 2022
34e4f46
TemplateDataFunc -> HTMLTemplateHandler
bryphe-coder Feb 8, 2022
0743503
Add return to reduce indentation in serveFile
bryphe-coder Feb 8, 2022
4585c13
Remove call to remove file extension
bryphe-coder Feb 8, 2022
8f2b47d
Switch to register 404, return error and warn at toplevel
bryphe-coder Feb 8, 2022
19fcfac
Move ./nextrouter -> ./site/nextrouter
bryphe-coder Feb 8, 2022
8343923
Return error from handler
bryphe-coder Feb 8, 2022
4a5c353
Change dynamic route logging from Info -> Debug
bryphe-coder Feb 8, 2022
e4d031f
Merge main
bryphe-coder Feb 9, 2022
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
Prev Previous commit
Next Next commit
Fix embed_test
  • Loading branch information
bryphe-coder committed Feb 5, 2022
commit 92d4eb0fc04dd9d9f8b83c7edcf807a7f90cde25
4 changes: 3 additions & 1 deletion site/embed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import (

"github.com/stretchr/testify/require"

"cdr.dev/slog"

"github.com/coder/coder/site"
)

func TestIndexPageRenders(t *testing.T) {
t.Parallel()

srv := httptest.NewServer(site.Handler())
srv := httptest.NewServer(site.Handler(slog.Logger{}))

req, err := http.NewRequestWithContext(context.Background(), "GET", srv.URL, nil)
require.NoError(t, err)
Expand Down