question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redesign and refactor HTTP API's static file handling

See original GitHub issue

The way HTTP API resources handle static files could be improved. Here is a list of issues to be addressed over time.

public routeStaticDirectory(
    method: string,
    path: string,
    filePath: string,
    contentType?: string) {
  • Remove the method parameter. Anything other than “GET” doesn’t make sense for serving static files. (done in #26)
  • Provide a way to upload entire directories, not needing explicit file-by-file declarations.
  • Enable regular expression captures, e.g. “/static/([^/]+)/(.)+” -> “/$1/$2”
  • Compare the design with Rest, Heroku, GAE, and other providers. Ensure we have feature parity. (See #4 for reference.)

Related issues:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
joeduffycommented, Aug 15, 2017
0reactions
lukehobancommented, Oct 30, 2017

If you are suggesting that the static routing do something unique to knowing what files are on disk in determining what routes it will wire up - that’s possible - but even further away from Express semantics (where static is just middleware, and has no direct visibility in routing). And it doesn’t generalize at all into other routing.

I think we should continue the discussion on #4 with a proposal on what it would mean to take a fundamentally different approach here that aligns deeply with Express. I’m very open to that - I’d feel much better if I had a high confidence approach that would get us there. And I don’t believe it’s impossible - I just don’t yet know how to do it yet. I’ll plan to do another pass at a strategy we could take that would get closer to Express semantics as part of 0.9.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building an ASP.NET Web API with ASP.NET Core - Toptal
ASP.NET Core is a leaner and more modular redesign of ASP.NET 4.x. Build a robust RESTful API using ASP.NET Core, EF Core, AutoMapper,...
Read more >
Refactoring Towards Expressive REST APIs: Let Your Code ...
In this post, Pivotal Labs Engineering Manager, David Julia, provides an example of a problematic RESTful JSON API and an approach for ...
Read more >
Automatically Generating Refactorings to Support API Evolution
Abstract. When library APIs change, client code should change in response, in order to avoid erroneous behavior, compilation failures, or warn-.
Read more >
Refactoring Static File System Access | Blog - Ardalis
The first step in modifying this code to be unit testable is to create an abstraction to replace the file system operations being...
Read more >
Code Refactoring Best Practices: When (and When Not) to Do It
Code refactoring is a process used in the DevOps philosophy that involves editing and cleaning up previously written code without changing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found