Skip to content

Commit d182395

Browse files
committed
feat(framework): added default constants
1 parent 9be792c commit d182395

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

framework/framework.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package framework
22

3-
import (
4-
// Import problem package for side effects to ensure RFC 7807 Problem Details
5-
// for HTTP APIs are available to middleware that depend on structured error
6-
// responses. This blank import initializes the package without direct usage.
7-
_ "github.com/studiolambda/cosmos/problem"
8-
9-
"github.com/studiolambda/cosmos/router"
10-
)
3+
import "github.com/studiolambda/cosmos/router"
114

125
// Router is the HTTP router type used by Cosmos applications.
136
// It provides routing functionality with support for path parameters,
@@ -38,7 +31,7 @@ type Middleware = router.Middleware[Handler]
3831
// Example usage:
3932
//
4033
// app := framework.New()
41-
// app.GET("/users/{id}", getUserHandler)
34+
// app.Get("/users/{id}", getUserHandler)
4235
// http.ListenAndServe(":8080", app)
4336
func New() *Router {
4437
return router.New[Handler]()

framework/hash/bcrypt/hasher.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ type Options struct {
1414
cost int
1515
}
1616

17+
const DefaultCost = 10
18+
1719
func NewHasher() *Hasher {
1820
return NewHasherWith(Options{
19-
cost: 10,
21+
cost: DefaultCost,
2022
})
2123
}
2224

framework/middleware/session.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ type SessionOptions struct {
2323
ExpirationDelta time.Duration
2424
}
2525

26-
var DefaultSessionCookie = "cosmos.session"
27-
var DefaultSessionExpirationDelta = 15 * time.Minute
28-
var DefaultSessionTTL = 2 * time.Hour
26+
const DefaultSessionCookie = "cosmos.session"
27+
const DefaultSessionExpirationDelta = 15 * time.Minute
28+
const DefaultSessionTTL = 2 * time.Hour
2929

3030
func currentSession(r *http.Request, driver contract.SessionDriver, options SessionOptions) (contract.Session, error) {
3131
id := request.CookieValue(r, options.Name)

0 commit comments

Comments
 (0)