-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CREATE] server package for HTTP server (#33) #33
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also the build folder to be wiped, that comes from running the make commands |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/CyberRoute/bruter/pkg/handlers" | ||
"github.com/CyberRoute/bruter/pkg/models" | ||
"github.com/go-chi/chi/v5" | ||
"net/http" | ||
) | ||
|
||
func Routes(mux *chi.Mux, homeArgs models.HomeArgs, sslArgs, whoIsArgs models.TemplateData) { | ||
mux.Get("/", handlers.Repo.Home(homeArgs)) | ||
mux.Get("/ssl", handlers.Repo.SSLInfo(sslArgs)) | ||
mux.Get("/whois", handlers.Repo.WhoisInfo(whoIsArgs)) | ||
mux.Get("/consumer", handlers.Repo.Consumer) | ||
fileServer := http.FileServer(http.Dir("./static/")) | ||
mux.Handle("/static/*", http.StripPrefix("/static", fileServer)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/CyberRoute/bruter/pkg/config" | ||
midd "github.com/CyberRoute/bruter/pkg/server/middleware" | ||
"github.com/CyberRoute/bruter/pkg/server/routes" | ||
"github.com/go-chi/chi/v5" | ||
"github.com/go-chi/chi/v5/middleware" | ||
) | ||
|
||
func NewServer(app *config.AppConfig) *chi.Mux { | ||
mux := chi.NewRouter() | ||
|
||
mux.Use(middleware.Recoverer) | ||
mux.Use(midd.SessionLoad) | ||
|
||
homeArgs, sslArgs, whoIsArgs := RunConfiguration(app) | ||
|
||
routes.Routes(mux, homeArgs, sslArgs, whoIsArgs) | ||
|
||
return mux | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want to remove the .idea folder, the gitignore is not complete since I develop on linux I didn't bother to add that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will put .idea folder in .gitignore for future