GithubHelp home page GithubHelp logo

Comments (3)

pkulchenko avatar pkulchenko commented on May 27, 2024 1

Labeling worked :) how do I label paths with "/:name"?

I'd expect "/:name*label" to work, as :name would consume whatever is consumable.

PATH+METHOD+HOST (if host = "...")?

I considered that earlier, but what makes host really special comparing to all other headers/parameters? Besides, I've seen many cases where HOST is not enough, so the user would still run into the same situation.

I have this peculiarity documented (see the third paragraph here: https://github.com/pkulchenko/fullmoon?tab=readme-ov-file#splat-parameters), but I welcome suggestion on how to make it more prominent.

from fullmoon.

pkulchenko avatar pkulchenko commented on May 27, 2024

Interesting; can you share the actual values you use and what the host value is when it fails to match? Something like this works for me (and this is in fact what I use in my code):

fm.setRoute({"/*routewww", host = "www.foobar.com"},
  function() return fm.serveRedirect(fm.makeUrl{host = "foobar.com"}) end)
fm.setRoute({"/*routeexamples", host = "examples.foobar.com"}, function(r)
    r.host = "examples.foobar.co" -- you can reassign the host too for subsequent matches
    return false
  end)

I suspect what happens is that your second route overwrites the first route, as the route are only unique for PATH+METHOD combination. I thought I had a warning for this, but may need to check. This is why I use *label at the end of the path to make them distinct.

Suggestion: make the fm.setRoute function find routes using the host parameter as priority

Any filter you specify is going to be applied in exactly the same way, so using the host header here should work.

from fullmoon.

Propagram avatar Propagram commented on May 27, 2024

Interesting; can you share the actual values you use and what the host value is when it fails to match?

-- host 1: dev.convert-2.com:8443 (fail)

fm.setRoute({
    host = "dev.convert-2.com",
    "/",             -- /*convert2
    method = "GET"
}, fm.serveContent("/convert-2/luaconvert", {
    tools = tools,
    categories = categories,
    main = main,
    title = title,
    total = #tools,
    year = os.date("%Y")
}))

-- host 2: dev.awesome-awesome.com:8443

fm.setRoute({
    host = "dev.awesome-awesome.com",
    "/",             -- /*awesome
    method = "GET"
}, fm.serveContent("/awesome-awesome/index", {}))

This is why I use *label at the end of the path to make them distinct.

Labeling worked :) how do I label paths with "/:name"?

I thought I had a warning for this, but may need to check

PATH+METHOD+HOST (if host = "...")?

Thanks!

from fullmoon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.