resource.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2017 fatedier, fatedier@gmail.com
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package vhost
  15. import (
  16. "io/ioutil"
  17. "net/http"
  18. "strings"
  19. "github.com/fatedier/frp/utils/version"
  20. )
  21. const (
  22. NotFound = `<!DOCTYPE html>
  23. <html>
  24. <head>
  25. <title>Not Found</title>
  26. <style>
  27. body {
  28. width: 35em;
  29. margin: 0 auto;
  30. font-family: Tahoma, Verdana, Arial, sans-serif;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <h1>The page you visit not found.</h1>
  36. <p>Sorry, the page you are looking for is currently unavailable.<br/>
  37. Please try again later.</p>
  38. <p>The server is powered by <a href="https://github.com/fatedier/frp">frp</a>.</p>
  39. <p><em>Faithfully yours, frp.</em></p>
  40. </body>
  41. </html>
  42. `
  43. )
  44. func notFoundResponse() *http.Response {
  45. header := make(http.Header)
  46. header.Set("server", "frp/"+version.Full())
  47. header.Set("Content-Type", "text/html")
  48. res := &http.Response{
  49. Status: "Not Found",
  50. StatusCode: 404,
  51. Proto: "HTTP/1.0",
  52. ProtoMajor: 1,
  53. ProtoMinor: 0,
  54. Header: header,
  55. Body: ioutil.NopCloser(strings.NewReader(NotFound)),
  56. }
  57. return res
  58. }