32e7468eef
len(path) moved down to where it is used.
2023-09-05 17:56:02 +04:00
3e6d03db1a
Added a test for path parsing and benchmarks for newPath and newServePath.
2023-09-05 06:03:29 +04:00
c237f8c566
Moved httpr_test.go to httpr package to get access to private funcs.
2023-09-05 06:02:56 +04:00
a23264b00f
Added a notice to a comment for Handler() method.
2023-09-05 06:02:11 +04:00
b4163d2162
StatusMethodNotAllowed was replaced by a correct StatusNotImplemented for if there is no tree for such method.
2023-09-05 06:01:30 +04:00
5d613b34ee
Added a newServePath() func that is a special variant of newPath that is used in ServeHTTP (it lacks an unnecessary check for * catch-all symbol).
2023-09-05 06:00:42 +04:00
cc2cd72df8
A little optimisation of newPath() func.
2023-09-05 05:58:29 +04:00
92692454da
Inversed logic of if else statement to reduce nesting by 1.
2023-08-12 19:37:51 +04:00
a2cb6182e8
Updated comments.
2023-08-12 19:19:45 +04:00
aba211f3ec
Renamed a root var to a more logically suitable name base.
2023-08-12 19:19:04 +04:00
d53622908b
Shortened a Router.Handler() method by removing if statement in the end, here just returning a result of add() func is sufficient.
2023-08-12 18:56:50 +04:00
7c8baeecf5
Changed error messages in newPath().
2023-08-12 18:55:00 +04:00
468606e4fd
Also added sub-path to an example in the README.md.
2023-08-11 18:46:49 +04:00
d9e5024d4d
Add an outer label to this continue statement as well. Just for good looking. :)
2023-08-11 18:45:17 +04:00
c68d7b324a
A test for Sub-path functionality.
2023-08-11 18:42:46 +04:00
3cb32c5ec9
Sub-path implemented, now you can make a sub for a section using Router's Sub(root) method and then write only what this section contains. Like s := Sub("/api/v1") and then s.Handler("/").
2023-08-11 18:42:28 +04:00
0717a2e3d3
In case a path continues, but no child was found then break out of main for loop.
...
It was a bug that when there are children in the next node, but no parameterised one, having a non-existent path element caused the main loop to continue and firing an if pathLen == i+1 case like if there was a legit node found.
2023-08-11 18:36:13 +04:00
e25a8a42c3
A year and copyright holders weren't filled in a LICENSE, LOL.
2023-07-23 23:27:49 +04:00
bc11a46806
Added a test for paths.
2023-07-23 23:26:35 +04:00
33de30fe23
Sanitise double slashes, and return nil in get() if a path continues but a node doesn't have children.
2023-07-23 23:19:58 +04:00
5d6a3630c6
Updated README.md.
2023-05-28 04:00:54 +04:00
fcbd09506a
Add a test.
2023-05-28 03:46:09 +04:00
2bfaae11f2
Fixed a typo in get().
2023-05-28 03:18:15 +04:00
257bd7ea76
Check if param names differ.
2023-05-28 03:17:53 +04:00
653bae85f5
Changed comment for Param().
2023-05-28 03:16:41 +04:00
4f54ab4156
Found and fixed a typo. n -> curNode.
2023-05-28 02:43:09 +04:00
9cda541108
Made ServeStatic() to return an error.
2023-05-28 01:49:21 +04:00
89c2333a4f
get and add methods get rewritten in an iterative manner instead of recursive.
2023-05-28 01:46:57 +04:00
538f1bd676
Removed / check that is performed in newPath. Return Not Acceptable if a path not starting with /.
2023-05-28 01:29:01 +04:00
a0b80ced85
Let Handler() return an error instead of panicking. Also removed checks for / and * since they are checked in newPath().
2023-05-28 01:24:18 +04:00
99a7cebd0a
Perform checks for / and * inside a newPath func.
2023-05-28 01:22:28 +04:00
5d7d595df3
Init repo!
2023-05-26 04:06:35 +04:00
9816fc01d1
Initial commit
2023-05-26 01:50:54 +04:00