kopia lustrzana https://codeberg.org/Codeberg/pages-server
				
				
				
			remove use of rawInfoPage redirect (#261)
closes #244 Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/261 Co-authored-by: crapStone <crapstone01@gmail.com> Co-committed-by: crapStone <crapstone01@gmail.com>pull/264/head
							rodzic
							
								
									cbb2ce6d07
								
							
						
					
					
						commit
						fffb8ffcb6
					
				|  | @ -72,13 +72,6 @@ var ( | |||
| 			EnvVars: []string{"RAW_DOMAIN"}, | ||||
| 			Value:   "raw.codeberg.page", | ||||
| 		}, | ||||
| 		// RawInfoPage will be shown (with a redirect) when trying to access RawDomain directly (or without owner/repo/path).
 | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "raw-info-page", | ||||
| 			Usage:   "will be shown (with a redirect) when trying to access $RAW_DOMAIN directly (or without owner/repo/path)", | ||||
| 			EnvVars: []string{"RAW_INFO_PAGE"}, | ||||
| 			Value:   "https://docs.codeberg.org/codeberg-pages/raw-content/", | ||||
| 		}, | ||||
| 
 | ||||
| 		// #########################
 | ||||
| 		// ### Page Server Setup ###
 | ||||
|  |  | |||
|  | @ -47,7 +47,6 @@ func Serve(ctx *cli.Context) error { | |||
| 	rawDomain := ctx.String("raw-domain") | ||||
| 	defaultBranches := ctx.StringSlice("pages-branch") | ||||
| 	mainDomainSuffix := ctx.String("pages-domain") | ||||
| 	rawInfoPage := ctx.String("raw-info-page") | ||||
| 	listeningHost := ctx.String("host") | ||||
| 	listeningSSLPort := ctx.Uint("port") | ||||
| 	listeningSSLAddress := fmt.Sprintf("%s:%d", listeningHost, listeningSSLPort) | ||||
|  | @ -137,7 +136,6 @@ func Serve(ctx *cli.Context) error { | |||
| 	// Create ssl handler based on settings
 | ||||
| 	sslHandler := handler.Handler(mainDomainSuffix, rawDomain, | ||||
| 		giteaClient, | ||||
| 		rawInfoPage, | ||||
| 		BlacklistedPaths, allowedCorsDomains, | ||||
| 		defaultBranches, | ||||
| 		dnsLookupCache, canonicalDomainCache, redirectsCache) | ||||
|  |  | |||
|  | @ -21,7 +21,6 @@ const ( | |||
| // Handler handles a single HTTP request to the web server.
 | ||||
| func Handler(mainDomainSuffix, rawDomain string, | ||||
| 	giteaClient *gitea.Client, | ||||
| 	rawInfoPage string, | ||||
| 	blacklistedPaths, allowedCorsDomains []string, | ||||
| 	defaultPagesBranches []string, | ||||
| 	dnsLookupCache, canonicalDomainCache, redirectsCache cache.SetGetKey, | ||||
|  | @ -89,7 +88,7 @@ func Handler(mainDomainSuffix, rawDomain string, | |||
| 		if rawDomain != "" && strings.EqualFold(trimmedHost, rawDomain) { | ||||
| 			log.Debug().Msg("raw domain request detected") | ||||
| 			handleRaw(log, ctx, giteaClient, | ||||
| 				mainDomainSuffix, rawInfoPage, | ||||
| 				mainDomainSuffix, | ||||
| 				trimmedHost, | ||||
| 				pathElements, | ||||
| 				canonicalDomainCache, redirectsCache) | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ import ( | |||
| ) | ||||
| 
 | ||||
| func handleRaw(log zerolog.Logger, ctx *context.Context, giteaClient *gitea.Client, | ||||
| 	mainDomainSuffix, rawInfoPage string, | ||||
| 	mainDomainSuffix string, | ||||
| 	trimmedHost string, | ||||
| 	pathElements []string, | ||||
| 	canonicalDomainCache, redirectsCache cache.SetGetKey, | ||||
|  | @ -25,8 +25,12 @@ func handleRaw(log zerolog.Logger, ctx *context.Context, giteaClient *gitea.Clie | |||
| 	log.Debug().Msg("raw domain") | ||||
| 
 | ||||
| 	if len(pathElements) < 2 { | ||||
| 		// https://{RawDomain}/{owner}/{repo}[/@{branch}]/{path} is required
 | ||||
| 		ctx.Redirect(rawInfoPage, http.StatusTemporaryRedirect) | ||||
| 		html.ReturnErrorPage( | ||||
| 			ctx, | ||||
| 			"a url in the form of <code>https://{domain}/{owner}/{repo}[/@{branch}]/{path}</code> is required", | ||||
| 			http.StatusBadRequest, | ||||
| 		) | ||||
| 
 | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -16,7 +16,6 @@ func TestHandlerPerformance(t *testing.T) { | |||
| 	testHandler := Handler( | ||||
| 		"codeberg.page", "raw.codeberg.org", | ||||
| 		giteaClient, | ||||
| 		"https://docs.codeberg.org/pages/raw-content/", | ||||
| 		[]string{"/.well-known/acme-challenge/"}, | ||||
| 		[]string{"raw.codeberg.org", "fonts.codeberg.org", "design.codeberg.org"}, | ||||
| 		[]string{"pages"}, | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 crapStone
						crapStone