added comments

This commit is contained in:
u80864958
2025-05-02 10:39:35 +02:00
parent fb7d5a623a
commit 14b57b57e8
16 changed files with 73 additions and 29 deletions

View File

@ -2,6 +2,7 @@ package cors
import "net/http"
// HandlerForOrigin returns a CORS middleware function that sets headers based on the requested origin.
func HandlerForOrigin(origin string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@ -22,6 +23,7 @@ func HandlerForOrigin(origin string) func(http.Handler) http.Handler {
}
}
// DeafaultHandler: Returns a handler that allows requests from any origin by delegating to a handler that allows all origins.
func DeafaultHandler(next http.Handler) http.Handler {
return HandlerForOrigin("*")(next)
}