Basic app structure
This commit is contained in:
parent
eaf4b6a239
commit
8685efeb8e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
|
go-bouquins
|
||||||
|
19
bouquins/bouquins.go
Normal file
19
bouquins/bouquins.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package bouquins
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
type Bouquins struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Bouquins) IndexPage(res http.ResponseWriter, req *http.Request) {
|
||||||
|
http.Redirect(res, req, "/html/index.html", http.StatusSeeOther)
|
||||||
|
}
|
||||||
|
func (*Bouquins) BooksPage(res http.ResponseWriter, req *http.Request) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
func (*Bouquins) AuthorsPage(res http.ResponseWriter, req *http.Request) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
func (*Bouquins) SeriesPage(res http.ResponseWriter, req *http.Request) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
40
main.go
Normal file
40
main.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"meutel.net/meutel/go-bouquins/bouquins"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
INDEX = "/"
|
||||||
|
BOOKS = "/books"
|
||||||
|
AUTHORS = "/authors"
|
||||||
|
SERIES = "/series"
|
||||||
|
HTML = "/html/"
|
||||||
|
JS = "/js/"
|
||||||
|
CSS = "/css/"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
app := new(bouquins.Bouquins)
|
||||||
|
assets()
|
||||||
|
router(app)
|
||||||
|
}
|
||||||
|
|
||||||
|
func assets() {
|
||||||
|
http.Handle(HTML, http.FileServer(http.Dir("assets")))
|
||||||
|
http.Handle(JS, http.FileServer(http.Dir("assets")))
|
||||||
|
http.Handle(CSS, http.FileServer(http.Dir("assets")))
|
||||||
|
}
|
||||||
|
|
||||||
|
func router(app *bouquins.Bouquins) {
|
||||||
|
http.HandleFunc(INDEX, app.IndexPage)
|
||||||
|
http.HandleFunc(BOOKS, app.BooksPage)
|
||||||
|
http.HandleFunc(AUTHORS, app.AuthorsPage)
|
||||||
|
http.HandleFunc(SERIES, app.SeriesPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.ListenAndServe(":9000", nil)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user