Comments (7)
I have discussed this with @koddr, and we want to share our conclusion on this matter.
Most methods that use the ...interface{}
argument are used for app.METHODS
to register routes with an optional path. We think that this is straightforward because this is the first thing you learn visiting Fiber or coming from Express.
Now there are some Context
methods that accept ...interface{}
as an argument:
ctx.Body
, ctx.Cookies
, ctx.Format
When you managed to understand the Route handlers, you are left with these 3
+/- methods where you need docs. So I think Fiber is still a strong typed API besides these 3 methods. But we could improve the above methods and maybe all Route handlers (except Use
).
I started working on clarifying some *Ctx
functions, these are safe changes to make.
master...Fenny:master
We can change all app.METHODS
to have a required (path string, handlers ...func(*Ctx))
for the following methods:
Static
, Connect
, Put
, Delete
, Head
, Patch
, Options
, Trace
, Get
, All
.
This is a big change, and I might create an Poll for this and take a vote.
from fiber.
I see.
Well, it is up to library maintainers to decide. I feel like having non strongly typed API can turn off some Go developers. Would be nice to have Β―\_(γ)_/Β―
.
In my case I added fiber
to dependencies, started to write main
function to try around and hit app.
autocompletion, saw args ...interface{}
and was like: damn... now I need to go find docs.
And not to mention I'm a member of strongly typed camp. π
from fiber.
agreeοΌFiber made it easy for me to migrate from nodejs to Goγ
The reason I chose to learn Go instead of TypeScript:
- A strong typed language can reduce errors and catch exceptions more easily
- Moderate development efficiency and adequate operational performance
- Cross-compile into binaries for easy distribution and deployment
Now, it's true that docs are often needed οΌand Some exceptions can only be caught at runtime.
from fiber.
Thanks @alex-shpak for your input, all suggestions will be addressed in v1.8.0.
PS: We went with Get(path string, handlers ...func(*Ctx))
because we don't want to confuse people with the order of where to place the middleware handlers.
app.Get("/", secretpage(), auth())
// Might cause unintended results since auth() will run after the secretpage
app.Get("/", auth(), secretpage())
// We think with the current arg types this will be encouraged.
I'm closing this issue because v1.8.0
will be released soon, feel free to re-open for more ideas/suggestions!
from fiber.
Thanks for opening your first issue here! π Be sure to follow the issue template!
from fiber.
Fiber started as a personal project to be able to rewrite all my node apps into Go. I tried to stick to the same workflow as Express by using interfaces when a function had multiple purposes, now I know that this is not the best way to go.
I thought about going with a 100% strong typed API weeks ago, but Fiber got a lot of users within a short period of time. So changing Fiber to be a fully strong typed framework will break the current API, but we can take notes for v1.8
from fiber.
I like that π
I guess Static
method would be Static(string, ...string)
. Also for method functions something like this might be good: Get(path string, handler func(*Ctx), handlers ...func(*Ctx)
so it requires to have at least one handler, or more.
I think having strong typing could cleanup router.go@register
function and make it more safe.
I cant help with some PRs if you have something specific in mind.
from fiber.
Related Issues (20)
- π [Proposal]: Improving route matching and url parsing performance with Ada Url HOT 7
- Improve Error Handling in CSRF Middleware Storage
- π€ [Question]: v3 when ready for production HOT 1
- π [Bug]: Unclear "json: invalid use of ,string struct tag, trying to unmarshal unquoted value into uint64" HOT 9
- π€ [Question]: Cache Next is not called when KeyGenerator is Defined HOT 6
- π [Bug]: v3 Flash Message with redirect is not working HOT 3
- π [Proposal]: Upgrade fiber.NewError() for error handle HOT 4
- π [Proposal]: Reduce memory usage for "prefork" mode of the master process HOT 2
- π§Ή [Maintenance]: Add Parallel Benchmarks
- π€ [Question]: zero allocation - why is this any different from how Chi or others behave? Can you document an example of what you mean? HOT 8
- π€ [Question]: FX with Fiber graceful shutdown Failed to stop cleanly: context deadline exceeded HOT 15
- π€ [Question]: whats the session id injection issue in github report HOT 4
- π [Bug]: Mutex issues with Idempotency middleware
- π [Bug]: Logger module causes OOM with ${bytesSent} and ${bytesReceived} HOT 10
- π€ [Question]: limiter supports dynamic setting of βMaxβ parameter HOT 8
- π [Proposal]: Add StartupProbe support to healthcheck Middleware HOT 6
- [Question]: Can't debug in Goland in Routes HOT 2
- π [Bug]: cache middleware: runtime error: index out of range [0] with length 0 HOT 15
- π [Proposal]: Get session by its ID HOT 1
- π [Proposal]: Support for Application State Management HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.