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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"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 {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
extension = "md"
|
||||
notesdir = "saved_notes"
|
||||
port = 8080
|
||||
address = ":8080"
|
||||
protocol = "tcp"
|
||||
|
||||
[templates]
|
||||
dir = "templates"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ func (asset *Asset) FetchIfNotExists(staticPath string) {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
Port int
|
||||
Address string
|
||||
Protocol string
|
||||
Extension string
|
||||
NotesDir string
|
||||
Templates struct {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue