Skip to content

workless example for routing with custom server #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
foi opened this issue Aug 18, 2019 · 3 comments
Open

workless example for routing with custom server #9

foi opened this issue Aug 18, 2019 · 3 comments

Comments

@foi
Copy link

foi commented Aug 18, 2019

Hi, Vlad! Awesome framework, but i have some issues:

crystal: 0.30.0

shards.lock

version: 1.0
shards:
  callbacks:
    github: vladfaust/callbacks.cr
    version: 0.2.0

  dotenv:
    github: gdotdesign/cr-dotenv
    version: 0.1.0

  exception_page:
    github: crystal-loot/exception_page
    version: 0.1.2

  http-params-serializable:
    github: vladfaust/http-params-serializable
    version: 0.4.0

  kilt:
    github: jeromegn/kilt
    version: 0.4.0

  onyx:
    github: onyxframework/onyx
    version: 0.6.1

  onyx-http:
    github: onyxframework/http
    version: 0.9.0

  radix:
    github: luislavena/radix
    version: 0.3.9

  time_format:
    github: vladfaust/time_format.cr
    version: 0.1.1

Example from here https://docs.onyxframework.org/http/advanced/custom-server.html#routing

require "onyx-http"

logger = Onyx::HTTP::Logger.new
request_id = Onyx::HTTP::RequestID.new
response_time = Onyx::HTTP::ResponseTime.new

router = Onyx::HTTP::Router.new do
  get "/" do |env|
    env.response << "Hello Onyx"
  end

  post "/echo" do |env|
    env.response << env.request.body.try &.gets_to_end
  end
end

server = Onyx::HTTP::Server.new(response_time, request_id, logger, router)

server.bind_tcp(5000)
server.listen

I have Error: undefined constant Onyx::HTTP::Logger and if comment this line have error in next line Error: undefined constant Onyx::HTTP::RequestID and so on

@vladfaust
Copy link
Member

Hello, @foi. Sorry, but that "advanced server guide" is utterly old. I keep it for historical purposes only 😅

@foi
Copy link
Author

foi commented Aug 18, 2019

As i can see an actual example to create custom server https://github.com/onyxframework/http/blob/master/src/onyx-http/middleware/router.cr - passing an array of handlers like for classic crystal HTTP::Server

@vladfaust
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants