github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/traceviewer/http.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package traceviewer
     6  
     7  import (
     8  	"github.com/shogo82148/std/net/http"
     9  )
    10  
    11  func MainHandler(views []View) http.Handler
    12  
    13  const CommonStyle = `
    14  /* See https://github.com/golang/pkgsite/blob/master/static/shared/typography/typography.css */
    15  body {
    16    font-family:	-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
    17    font-size:	1rem;
    18    line-height:	normal;
    19    max-width:	9in;
    20    margin:	1em;
    21  }
    22  h1 { font-size: 1.5rem; }
    23  h2 { font-size: 1.375rem; }
    24  h1,h2 {
    25    font-weight: 600;
    26    line-height: 1.25em;
    27    word-break: break-word;
    28  }
    29  p  { color: grey85; font-size:85%; }
    30  code,
    31  pre,
    32  textarea.code {
    33    font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    34    font-size: 0.875rem;
    35    line-height: 1.5em;
    36  }
    37  
    38  pre,
    39  textarea.code {
    40    background-color: var(--color-background-accented);
    41    border: var(--border);
    42    border-radius: var(--border-radius);
    43    color: var(--color-text);
    44    overflow-x: auto;
    45    padding: 0.625rem;
    46    tab-size: 4;
    47    white-space: pre;
    48  }
    49  `
    50  
    51  type View struct {
    52  	Type   ViewType
    53  	Ranges []Range
    54  }
    55  
    56  type ViewType string
    57  
    58  const (
    59  	ViewProc   ViewType = "proc"
    60  	ViewThread ViewType = "thread"
    61  )
    62  
    63  func (v View) URL(rangeIdx int) string
    64  
    65  type Range struct {
    66  	Name      string
    67  	Start     int
    68  	End       int
    69  	StartTime int64
    70  	EndTime   int64
    71  }
    72  
    73  func (r Range) URL(viewType ViewType) string
    74  
    75  func TraceHandler() http.Handler
    76  
    77  func StaticHandler() http.Handler