-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from johnsiilver/README
Readme and examples
- Loading branch information
Showing
46 changed files
with
1,894 additions
and
150 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
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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/johnsiilver/webgear/handlers" | ||
|
||
. "github.com/johnsiilver/webgear/html" | ||
) | ||
|
||
var ( | ||
dev = flag.Bool("dev", false, "Prevents the browser from caching content when doing development") | ||
port = flag.Int("port", 9568, "The port to server on") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
doc := &Doc{ | ||
Head: &Head{ | ||
Elements: []Element{ | ||
&Meta{Charset: "utf-8"}, | ||
&Title{TagValue: TextElement("Hello World")}, | ||
&Link{ | ||
Rel: "stylesheet", | ||
Href: URLParse("/static/index/index.css"), | ||
}, | ||
}, | ||
}, | ||
Body: &Body{ | ||
Elements: []Element{ | ||
&H{ | ||
GlobalAttrs: GlobalAttrs{ | ||
Class: "pageText", | ||
}, | ||
Level: 1, | ||
Elements: []Element{ | ||
TextElement("Hello World"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
opts := []handlers.Option{} | ||
if *dev { | ||
opts = append( | ||
opts, | ||
handlers.DoNotCache(), | ||
) | ||
} | ||
|
||
h := handlers.New(opts...) | ||
|
||
// Serves up files ending with .css from /static/... | ||
h.ServeFilesWorkingDir([]string{".css"}) | ||
|
||
// Our doc will now be served at the index page. | ||
h.MustHandle("/", doc) | ||
|
||
// Serve the content using the http.Server. | ||
server := &http.Server{ | ||
Addr: fmt.Sprintf(":%d", *port), | ||
Handler: h.ServerMux(), | ||
ReadTimeout: 10 * time.Second, | ||
WriteTimeout: 10 * time.Second, | ||
MaxHeaderBytes: 1 << 20, | ||
} | ||
log.Printf("http server serving on :%d", *port) | ||
log.Fatal(server.ListenAndServe()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.pageText{ | ||
font-family: "Cursive"; | ||
color: blue; | ||
} |
Oops, something went wrong.