ref: cceb70f7849948ee9a2972899ae4cfd1cb8daec5
parent: 49d15932bf3a8d199a1190d2b3b4f24eeadead33
author: Halfwit <halfwit@MacBook-Pro.hitronhub.home>
date: Thu Dec 12 11:58:25 PST 2019
Move requests out to their own file
--- /dev/null
+++ b/router/request.go
@@ -1,0 +1,35 @@
+package router
+
+import (
+ "net/http"
+
+ "github.com/olmaxmedical/olmax_go/db"
+ "github.com/olmaxmedical/olmax_go/session"
+ "golang.org/x/text/message"
+)
+
+// Request represents an incoming GET/POST
+type Request struct {
+ printer *message.Printer
+ session session.Session
+ request *http.Request
+ user string
+ status string
+ path string
+ role db.Access
+}
+
+// Printer - returns the client's localized printer handler
+func (r *Request) Printer() *message.Printer {
+ return r.printer
+}
+
+// Session - returns the client's session
+func (r *Request) Session() session.Session {
+ return r.session
+}
+
+// Request - underlying http.Request for forms and such
+func (r *Request) Request() *http.Request {
+ return r.request
+}
--- a/router/run.go
+++ b/router/run.go
@@ -34,9 +34,9 @@
mux.HandleFunc("/", d.normal)
//from https://github.com/denji/golang-tls (creative commons)
srv := &http.Server{
- Addr: ":8443",
- Handler: mux,
- TLSConfig: getTlsConfig(),
+ Addr: ":8443",
+ Handler: mux,
+ TLSConfig: getTlsConfig(),
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0),
}
return srv.ListenAndServeTLS("cert.pem", "key.pem")
@@ -66,32 +66,6 @@
us.Set("token", token)
r.URL.Path = "/newpassword.html"
d.normal(w, r)
-}
-
-// Request represents an incoming GET/POST
-type Request struct {
- printer *message.Printer
- session session.Session
- request *http.Request
- user string
- status string
- path string
- role db.Access
-}
-
-// Printer - returns the client's localized printer handler
-func (r *Request) Printer() *message.Printer {
- return r.printer
-}
-
-// Session - returns the client's session
-func (r *Request) Session() session.Session {
- return r.session
-}
-
-// Request - underlying http.Request for forms and such
-func (r *Request) Request() *http.Request {
- return r.request
}
func (d *handle) normal(w http.ResponseWriter, r *http.Request) {