Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lancet
/
kvcache
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1c05ab46
authored
Aug 23, 2019
by
lancet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more to basic routing
parent
0e26ff4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
kvcache
+0
-0
main.go
+9
-0
No files found.
kvcache
View file @
1c05ab46
No preview for this file type
main.go
View file @
1c05ab46
...
...
@@ -20,6 +20,13 @@ func getValue(w http.ResponseWriter, r *http.Request) {
fmt
.
Fprint
(
w
,
resp
)
}
func
setValue
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
vars
:=
mux
.
Vars
(
r
)
id
:=
vars
[
"id"
]
resp
:=
fmt
.
Sprintf
(
"Set ID: %s
\n
"
,
id
)
fmt
.
Fprint
(
w
,
resp
)
}
func
delValue
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
vars
:=
mux
.
Vars
(
r
)
id
:=
vars
[
"id"
]
...
...
@@ -40,6 +47,8 @@ func main() {
router
:=
mux
.
NewRouter
()
routing
:=
[]
Route
{
{
"/storage/{id}"
,
[]
string
{
"GET"
},
getValue
},
{
"/storage/{id}"
,
[]
string
{
"PUT"
,
"POST"
},
setValue
},
{
"/storage/{id}"
,
[]
string
{
"DELETE"
},
delValue
},
}
initRouter
(
router
,
routing
)
http
.
Handle
(
"/"
,
router
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment