Skip to content

Latest commit

 

History

History
162 lines (147 loc) · 6.91 KB

TODO.md

File metadata and controls

162 lines (147 loc) · 6.91 KB

TODOs

Docs

  • replace - with em dash —_— —v— —^— —7—
  • name header file
  • ensure example + docs code runs
  • Use Fathom analytics
  • github workflows

Pre-release

  • SSL support

  • Cookies

  • Name this project: Ys?

  • Lock deps versions

  • Document

  • Filter out test deps in builds

  • Clean up all objects w/ free where necessary

  • Validate NULLs and allocated objects

  • Add logging

  • HTTP request parser

  • static

  • error-handling

  • properly parse entire request (we're using a placeholder method right now!)

  • Use a union to store parameter values. We have enough info from the regex to determine whether the value should be an int or char* - this would be a pain for users

  • pass a struct with context, req, res (maybe merge ctx and req)

  • integ tests

  • read entire request in chunks

  • send entire response in chunks

  • fix request hangups

    • mostly fixed, happens when calling with a not allowed/found method w/body Could not resolve host: <body> (was non-issue; using curl wrong :|)
  • prefix all enums with YS_METHOD_ or YS_STATUS_

  • handle duplicate request headers

    • Go style: append subsequent values, but Get retrieves the first only. Values returns list of all. In response, each duplicate header is written separately
  • xmalloc that dies

Perf

  • Increase to 15k TPS (As of 06/03/2023, Ys supports ~5k TPS. We want to improve this 3x to ~15k)

Testing

  • test handlers with a mocking library? no need w/ integ
  • test with a real server (E2E)

UX

  • cross-OS compatibility
    • source strdup from dep
  • review all included functions and replace any non-standard ones
  • documentation
  • make all public structs opaque
  • Use method enum in CORS middleware helpers
  • Ensure everything opaque has getters and setters
  • Deny list paths for middleware
    • Store URL in struct (if needed)
    • Allow the deny list to use regex
    • Handle paths with params etc
  • middleware ordering - before err handlers?
  • ask users - should CORS be inherited by sub-routers automatically? try an inherit mode
  • Non-param path regex
  • Offer Content-Types
  • Use hash set for headers to de-duplicate
  • Comma-delimit duplicate response headers
  • Use user-defined content length header OR overwrite it - but handle it
  • fmt string in ys_set_body
  • Default Content-Type to text/plain?
  • Remove the need for null-terminator everywhere else (incl ys_router_register)
  • set default status on registered fallback handlers with no ys_set_status call

New Features

  • global hooks/interceptors (e.g. global HTTP headers) just use middleware
  • allow middleware to exit early by sending response
  • Built-in middlewares
    • CORS middleware
  • Cookies
  • support erroneous (Request / Response)s
  • use attr struct for fallback handlers
  • Figure out file routing. The problem here is we want the response_t type to be accessible to consumers without having to compile the entire library and link it. Make this an addon
  • SSL/TLS support
  • JSON parsed body in context (decided to offer JSON opt-in utilities)
  • async i/o option using epoll
    • Fully evented server e.g. onRequest
  • global middlewares
  • multiple routers
  • handle signals for graceful shutdown
  • query strings
  • wildcard routing just use middleware
  • serve entire dir
  • set X-Powered-By nah, better to be less invasive

Best Practices

Spec Compliance

  • handle duplicate response headers
  • Full RFC compliance
    • handle accept header
    • Validate Content-Type for incoming stateful requests
    • keep-alive
    • cache-control
    • transfer-encoding
  • Test URL fragments
  • URL queries

Misc Improvements

  • use a better regex engine than pcre it's fine
  • make regex cache global (instead of per-trie-node) bad idea
  • replace LOG macro calls with new logger
    • fix log to stderr
    • use function name macro instead of explicit string literals
  • inline functions where reasonable
  • Change middleware chaining to use next, the next middleware in the chain. This will allow a current handler to not invoke next, thus ending the chain. Note: Figuring this out is going to be a challenge
  • relocate JSON to util library

DX

  • helper ??? #define CAST(type, name, stmt) type *name = (type *)stmt
  • Setup linter that uses Google's C/C++ style guide
  • @return doc for true and false cases instead of just bool
  • pick a style for struct types
  • Debug helpers e.g.
    static int c = 1;
    #define checkpoint() printf("CHECKPOINT %d\n", c++)
    #define isnull(thing) printf("IS NULL? %s\n", thing == NULL ? "yes" : "no")
  • Shared test utils
  • Consolidate integ test servers
  • get rid of doc comments with @param - it offers no value since we're not generating anything with the doc comments and is difficult to maintain
  • cleanup tests and use unified framework so we have full test count in aggregate, can filter tests, and have a reporter
  • Remove localhost SSL certs and add a script for developers to generate their own

Fixes

  • Allow OPTIONS requests by default in router when CORS enabled
  • Urls with - segfault e.g. /feed_meta/index-0.json
    • Add test
  • curl - Connection #0 to host localhost left intact? (see https://stackoverflow.com/a/72045706)
  • Address glibc malloc bug in ip
  • Do two route handlers with diff methods for the same /route get handled separately? Yes, it's per route/method. With GET / handlera and GET / handlerb, the most-recently registered will overwrite.
  • Does router handle URL fragments?
    • Failed curl localhost:9000/?cookie
    • Failed curl 'localhost:9000/?cookie=1&value=1'
  • Why does http req hang when using TLS?
  • Don't fallthrough to route handler on OPTIONS req
    • Middleware should run before the fallback handlers and routing - that will fix this.

Ecosystem

  • Addon / plugin libraries
    • Metrics
    • Testing (stubs, mock calls etc) (req, res)
    • User-logger that serializes opaque objects