Support any golang net supported protocol
This commit is contained in:
parent
b9af31e2f5
commit
cb6c12354a
3 changed files with 11 additions and 5 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
|
@ -27,8 +27,12 @@ func main() {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
addr := fmt.Sprintf(":%d", conf.Conf.Port)
|
|
||||||
log.Fatal(http.ListenAndServe(addr, router))
|
listener, err := net.Listen(conf.Conf.Protocol, conf.Conf.Address)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
log.Fatal(http.Serve(listener, router))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logger(next http.Handler) http.Handler {
|
func logger(next http.Handler) http.Handler {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
extension = "md"
|
extension = "md"
|
||||||
notesdir = "saved_notes"
|
notesdir = "saved_notes"
|
||||||
port = 8080
|
address = ":8080"
|
||||||
|
protocol = "tcp"
|
||||||
|
|
||||||
[templates]
|
[templates]
|
||||||
dir = "templates"
|
dir = "templates"
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ func (asset *Asset) FetchIfNotExists(staticPath string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int
|
Address string
|
||||||
|
Protocol string
|
||||||
Extension string
|
Extension string
|
||||||
NotesDir string
|
NotesDir string
|
||||||
Templates struct {
|
Templates struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue