-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* static registry should have only the template but not a path * file registry should ready the template * move logging into main.go * simplify tests * add command line arg tests
- Loading branch information
1 parent
b84bb2a
commit 1feb028
Showing
8 changed files
with
61 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -1,29 +1,21 @@ | ||
package noroute | ||
|
||
import ( | ||
"log" | ||
"sync/atomic" | ||
"sync/atomic" | ||
) | ||
|
||
var store atomic.Value // string | ||
|
||
func init() { | ||
store.Store("") | ||
store.Store("") | ||
} | ||
|
||
// GetHTML returns the HTML for not found routes. | ||
func GetHTML() string { | ||
return store.Load().(string) | ||
return store.Load().(string) | ||
} | ||
|
||
// SetHTML sets the current noroute html. | ||
// SetHTML sets the HTML for not found routes. | ||
func SetHTML(h string) { | ||
// html := HTML{h} | ||
store.Store(h) | ||
|
||
if h == "" { | ||
log.Print("[INFO] Unset noroute HTML") | ||
} else { | ||
log.Printf("[INFO] Set noroute HTML (%d bytes)", len(h)) | ||
} | ||
store.Store(h) | ||
} |
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 |
---|---|---|
@@ -1,19 +1,16 @@ | ||
package noroute | ||
|
||
import ( | ||
"testing" | ||
"testing" | ||
) | ||
|
||
func TestStoreSetGet(t *testing.T) { | ||
got := GetHTML() | ||
if got != "" { | ||
t.Fatalf("Expected unset noroute html to be an empty string, got %s", got) | ||
} | ||
if got, want := GetHTML(), ""; got != want { | ||
t.Fatalf("got unset noroute html %q want %q", got, want) | ||
} | ||
|
||
want := "<blink>Fancy!</blink>" | ||
SetHTML(want) | ||
got = GetHTML() | ||
if got != want { | ||
t.Fatalf("got %s, want %s", got, want) | ||
} | ||
SetHTML("foo") | ||
if got, want := GetHTML(), "foo"; got != want { | ||
t.Fatalf("got noroute html %q want %q", got, want) | ||
} | ||
} |
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
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