Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alterationx10 committed Dec 19, 2024
1 parent e17c244 commit f88b6a0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions site/src/spider/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ returning a response). These handlers are registered with a root URI to the serv

When a HTTP request is received, the appropriate `HttpContext` (and handler) is located by finding the context whose
path is the longest matching prefix of the request URI's path. Paths are matched literally, which means that the strings
are compared case sensitively.
are compared case sensitively, though there is a `ci` string interpolator to help with case-insensitive matching.

## Spider

Expand Down Expand Up @@ -54,9 +54,7 @@ trait ContextHandler(val path: String)
```

The main thing to implement here is the `contextRouter`. The `contextRouter` is a `PartialFunction` that matches the
http method/verb and request path and maps to a specific `Requesthandler`. The `Segments` type is an opaque type over a
`Seq[String]` with some helper methods. Most importantly and differently from the java documentation, the `Segments` we're
matching against has been lower cases, so the case sensitivity won't be as impacting to our routing.
http method/verb and request path and maps to a specific `Requesthandler`.

Here is an example:

Expand All @@ -71,7 +69,7 @@ case class EchoGetter(msg: String) extends RequestHandler[Unit, String] {
val myhandler = new ContextHandler("/") {

override val contextRouter
: PartialFunction[(HttpVerb, Segments), RequestHandler[?, ?]] = {
: PartialFunction[(HttpVerb, Path), RequestHandler[?, ?]] = {
case HttpVerb.GET -> >> / "some" / "path" => alohaGreeter
case HttpVerb.GET -> >> / "some" / "path" / s"$arg" => EchoGetter(arg)
}
Expand Down Expand Up @@ -117,7 +115,7 @@ object HttpAppExample extends HttpApp {
)

override val contextRouter
: PartialFunction[(HttpVerb, Segments), RequestHandler[?, ?]] = {
: PartialFunction[(HttpVerb, Path), RequestHandler[?, ?]] = {
case HttpVerb.GET -> >> / "some" / "path" => alohaGreeter
case HttpVerb.GET -> >> / "some" / "path" / s"$arg" => EchoGetter(arg)
}
Expand Down

0 comments on commit f88b6a0

Please sign in to comment.