diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-13 08:52:18 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-13 08:52:18 +0800 |
commit | 3397c837b9690ddf506b3162e55c33ab7cf902cf (patch) | |
tree | f99b0cf0d75bff05db00f1a8b7c37e149adb6fd1 | |
parent | login: Set cookie (diff) | |
download | forge-3397c837b9690ddf506b3162e55c33ab7cf902cf.tar.gz forge-3397c837b9690ddf506b3162e55c33ab7cf902cf.tar.zst forge-3397c837b9690ddf506b3162e55c33ab7cf902cf.zip |
handle_user: Stub
Diffstat (limited to '')
-rw-r--r-- | http_handle_users.go | 8 | ||||
-rw-r--r-- | http_server.go | 8 | ||||
-rw-r--r-- | templates/_header.html.tmpl | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/http_handle_users.go b/http_handle_users.go new file mode 100644 index 0000000..182ec53 --- /dev/null +++ b/http_handle_users.go @@ -0,0 +1,8 @@ +package main + +import ( + "net/http" +) + +func handle_users(w http.ResponseWriter, r *http.Request, params map[string]any) { +} diff --git a/http_server.go b/http_server.go index ddbe8ce..e769ace 100644 --- a/http_server.go +++ b/http_server.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "strings" + "strconv" ) type http_router_t struct{} @@ -48,7 +49,7 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { if _user_id == 0 { params["user_id"] = "" } else { - params["user_id"] = string(_user_id) + params["user_id"] = strconv.Itoa(_user_id) } if segments[0] == ":" { @@ -56,14 +57,15 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { case "login": handle_login(w, r, params) return + case "users": + handle_users(w, r, params) + return default: http.Error(w, fmt.Sprintf("Unknown system module type: %s", segments[1]), http.StatusNotFound) return } } - fmt.Printf("%#v\n", params) - separator_index := -1 for i, part := range segments { if part == ":" { diff --git a/templates/_header.html.tmpl b/templates/_header.html.tmpl index bfe386a..7c0e4ea 100644 --- a/templates/_header.html.tmpl +++ b/templates/_header.html.tmpl @@ -4,7 +4,7 @@ </div> <div> {{ if ne .user_id "" }} - <a href="/:/user/{{ .user_id }}">{{ .username }}</a> + <a href="/:/users/{{ .user_id }}">{{ .username }}</a> {{ else }} <a href="/:/login/">Login</a> {{ end }} |