To use GoCenter:
export GOPROXY=https://gocenter.io
bitbucket.org/briic/mango-v3
January 1st 0001
Last Modified
0
Stars
MIT
License
3
Downloads
ReadMe
Mod File
GoDocs
New
Security
Dependencies (0)
Used By (0)
Metrics
Versions
Mango

Serves markdown content as webpage.
Content structure
You can see content structure example in test-files/
.
Or find runnable example in folder example/
.
main.go
.mango
content/
en/
top-menu/
1_Home.md
2_About.md
...
footer-menu/
...
lv/
...
public/
favicon.png
images/
css/
js/
.mango
- config file
Domain: https://example.loc
ContentPath: content/
PublicPath: public/
PageURL: /{Lang}/{Slug}.html
FileURL: /{File}
Examples
Check out example/README
Example (simple)
First install with go get bitbucket.org/briiC/mango-v3
and use in code as import "bitbucket.org/briiC/mango-v3"
One-liner if you need basic webpage functionality.
#!go
package main
import "bitbucket.org/briiC/mango-v3"
func main() {
mango.NewServer(3000).Start()
}
Example (advanced)
Before starting webserver add custom stuff if you need advanced configuration.
#!go
package main
import "bitbucket.org/briiC/mango-v3"
func main() {
srv := mango.NewServer(3000)
// Add some middlewares ("File", "Page")
// srv.Middlewares["Page"] = mwForPage // assign one mw
// srv.Middlewares["File"] = mwForFile // assign one mw
srv.Middlewares["Page"] = func(next http.Handler) http.Handler {
return mwFirst(mwSecond(next))
}
// Custom functions for templates
srv.FuncMap = template.FuncMap{
"Smile": func() string {
return ":)"
},
"Add": func(a,b int) string {
return a + b
},
}
// Custom route
srv.Router.HandleFunc("/{Lang}/search/{sterm}", func(w http.ResponseWriter, r *http.Request) {
runSearch(srv, w, r) // create your handler
})
// Print all pages and info about them
srv.App.Print()
// Go!
log.Println("Start listening on", ":"+srv.Port)
panic( srv.Start() )
}
func mwFirst(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// do stuff
next.ServeHTTP(w, r)
})
}
func mwSecond(next http.Handler) http.Handler { ... }