bung87 / scorper

scorper is a micro and elegant web framework written in Nim
Apache License 2.0
81 stars 5 forks source link

req.url.path is no longer valid? #43

Closed treeform closed 1 year ago

treeform commented 1 year ago

I think some dependency have changed and I just nimble install it and it breaks right a way on the first example:

/home/me/.nimble/pkgs/scorper-1.0.26/scorper/http/streamserver.nim(782, 58) Error: type mismatch: got <Url:ObjectType>
but expected one of:
func path(url: Url): string
  first type mismatch at position: 1
  required type for url: Url
  but expression 'req.url' is of type: Url:ObjectType
Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2022-11-21
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f1519259f85cbdf2d5ff617c6a5534fcd2ff6942
active boot switches: -d:release
treeform commented 1 year ago

Seems like changing from req.url.path to just req.path in scorper/http/streamserver.nim fixes the issue.

bung87 commented 1 year ago

I've tried nim c .\examples\hello_world.nim and nim c .\examples\hello_world_with_router.nim in nim 1.6.10, urlly@0.2.0, urlly only support old version requires "urlly >= 0.2.0 & < 0.3.0"

bung87 commented 1 year ago

feel free to open if this still exists.

nimelias commented 9 months ago

urlly don't have path field

type
  Url* = ref object
    scheme*, username*, password*: string
    hostname*, port*, fragment*: string
    paths*: seq[string]
    query*: QueryParams

writen to

let path = r.url.paths.join("/")
  result = fmt"{r.hostname} - {remoteUser} {$now()} "{r.meth} {path} HTTP/{r.protocol.major}.{r.protocol.minor}" {status} {size}"

proc serveStatic have the same problem:

relPath = decodeUrlComponent(req.url.path.relativePath(cast[ImpRequest](req).prefix))