Greetings to all.

I have spent the last couple of evenings learning about Rust and trying it out. Wrote a simple cli calculator as a first thing and thought I would improve it by making it available over http.

I was actually a bit surprised to find that there was no http tooling in the standard library, and searching online gave me an overload of information on different libraries and frameworks.

I ended up implementing my own simple HTTP server, might as well as this is a learning project.

Now I have it working, and while it isn’t perfect or done, I thought that this would be a good time to check what things I am doing wrong/badly.

Which is why I am here, would love to get some pointers on it all to make sure I am going in the right direction in the future.

The project is hosted here: https://github.com/Tebro/rsimple_http

  • anlumo@feddit.de
    link
    fedilink
    arrow-up
    13
    ·
    1 year ago

    Please don’t use pointers in Rust!

    Anyways, my feedback:

    Your http module just wraps another inline module, this is unnecessary. Usually inline modules are only useful for tests. Your readline implementation doesn’t account for systems with two-character line endings (Windows and DOS) and I’m also unclear on why you need that for stdin.

    Concerning http in the standard library, Rust has learned from the mess in python, which has multiple implementations in the standard library that are all outdated but can’t be updated due to needing to handle backwards compatibility. Rust only has the basic stuff there, and handles other needs by external dependencies, which are managed by a great package manager (again, unlike python) on crates.io.

    • tebro@lemmy.tebro.fiOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      ah the IO module is left over from the initial CLI calculator. Will have to clean that out at some point.

      And the inline server module is also left over from when I was writing everything in the same file first before splitting out.

      Good catches! Thanks