github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/api/receiver/handlers.go (about) 1 // Copyright 2019 The WPT Dashboard Project. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package receiver 6 7 import ( 8 "net/http" 9 10 "github.com/web-platform-tests/wpt.fyi/api/checks" 11 ) 12 13 func apiResultsUploadHandler(w http.ResponseWriter, r *http.Request) { 14 if r.Method != http.MethodPost { 15 http.Error(w, "Only POST is supported", http.StatusMethodNotAllowed) 16 17 return 18 } 19 20 ctx := r.Context() 21 a := NewAPI(ctx) 22 HandleResultsUpload(a, w, r) 23 } 24 25 func apiResultsCreateHandler(w http.ResponseWriter, r *http.Request) { 26 if r.Method != http.MethodPost { 27 http.Error(w, "Only POST is supported", http.StatusMethodNotAllowed) 28 29 return 30 } 31 32 ctx := r.Context() 33 a := NewAPI(ctx) 34 s := checks.NewAPI(ctx) 35 HandleResultsCreate(a, s, w, r) 36 } 37 38 func apiPendingTestRunUpdateHandler(w http.ResponseWriter, r *http.Request) { 39 if r.Method != http.MethodPatch { 40 http.Error(w, "Only PATCH is supported", http.StatusMethodNotAllowed) 41 42 return 43 } 44 45 ctx := r.Context() 46 a := NewAPI(ctx) 47 HandleUpdatePendingTestRun(a, w, r) 48 }